Commit 3e9a18e
ftrace: bpf: Fix IPMODIFY + DIRECT in modify_ftrace_direct()
ftrace_hash_ipmodify_enable() checks IPMODIFY and DIRECT ftrace_ops on
the same kernel function. When needed, ftrace_hash_ipmodify_enable()
calls ops->ops_func() to prepare the direct ftrace (BPF trampoline) to
share the same function as the IPMODIFY ftrace (livepatch).
ftrace_hash_ipmodify_enable() is called in register_ftrace_direct() path,
but not called in modify_ftrace_direct() path. As a result, the following
operations will break livepatch:
1. Load livepatch to a kernel function;
2. Attach fentry program to the kernel function;
3. Attach fexit program to the kernel function.
After 3, the kernel function being used will not be the livepatched
version, but the original version.
Fix this by adding __ftrace_hash_update_ipmodify() to
__modify_ftrace_direct() and adjust some logic around the call.
Signed-off-by: Song Liu <song@kernel.org>
Reviewed-by: Jiri Olsa <jolsa@kernel.org>
Link: https://lore.kernel.org/r/20251027175023.1521602-3-song@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Steven Rostedt (Google) <rostedt@goodmis.org>1 parent 56b3c85 commit 3e9a18e
1 file changed
Lines changed: 31 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1971 | 1971 | | |
1972 | 1972 | | |
1973 | 1973 | | |
1974 | | - | |
| 1974 | + | |
| 1975 | + | |
1975 | 1976 | | |
1976 | 1977 | | |
1977 | 1978 | | |
| |||
2006 | 2007 | | |
2007 | 2008 | | |
2008 | 2009 | | |
2009 | | - | |
| 2010 | + | |
| 2011 | + | |
| 2012 | + | |
| 2013 | + | |
2010 | 2014 | | |
2011 | 2015 | | |
2012 | | - | |
| 2016 | + | |
2013 | 2017 | | |
2014 | 2018 | | |
2015 | 2019 | | |
| |||
2020 | 2024 | | |
2021 | 2025 | | |
2022 | 2026 | | |
2023 | | - | |
| 2027 | + | |
| 2028 | + | |
| 2029 | + | |
| 2030 | + | |
| 2031 | + | |
| 2032 | + | |
| 2033 | + | |
| 2034 | + | |
| 2035 | + | |
| 2036 | + | |
2024 | 2037 | | |
2025 | 2038 | | |
2026 | 2039 | | |
| |||
2076 | 2089 | | |
2077 | 2090 | | |
2078 | 2091 | | |
2079 | | - | |
| 2092 | + | |
2080 | 2093 | | |
2081 | 2094 | | |
2082 | 2095 | | |
| |||
2087 | 2100 | | |
2088 | 2101 | | |
2089 | 2102 | | |
2090 | | - | |
| 2103 | + | |
2091 | 2104 | | |
2092 | 2105 | | |
2093 | 2106 | | |
| |||
2101 | 2114 | | |
2102 | 2115 | | |
2103 | 2116 | | |
2104 | | - | |
| 2117 | + | |
2105 | 2118 | | |
2106 | 2119 | | |
2107 | 2120 | | |
| |||
6114 | 6127 | | |
6115 | 6128 | | |
6116 | 6129 | | |
6117 | | - | |
| 6130 | + | |
6118 | 6131 | | |
6119 | 6132 | | |
6120 | 6133 | | |
| |||
6134 | 6147 | | |
6135 | 6148 | | |
6136 | 6149 | | |
| 6150 | + | |
| 6151 | + | |
| 6152 | + | |
| 6153 | + | |
| 6154 | + | |
| 6155 | + | |
| 6156 | + | |
| 6157 | + | |
| 6158 | + | |
6137 | 6159 | | |
6138 | 6160 | | |
6139 | 6161 | | |
6140 | 6162 | | |
6141 | 6163 | | |
6142 | 6164 | | |
6143 | | - | |
6144 | 6165 | | |
6145 | 6166 | | |
6146 | 6167 | | |
| |||
6155 | 6176 | | |
6156 | 6177 | | |
6157 | 6178 | | |
| 6179 | + | |
6158 | 6180 | | |
6159 | 6181 | | |
6160 | 6182 | | |
| |||
0 commit comments