Commit e2c0ae2
committed
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_ipmodify_enable() to modify_ftrace_direct()
and adjust some logic around the call.
Signed-off-by: Song Liu <[email protected]>1 parent 3d6387a commit e2c0ae2
2 files changed
+38
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
224 | 231 | | |
225 | 232 | | |
226 | 233 | | |
| |||
479 | 486 | | |
480 | 487 | | |
481 | 488 | | |
482 | | - | |
483 | | - | |
484 | | - | |
485 | | - | |
486 | | - | |
487 | 489 | | |
488 | 490 | | |
489 | 491 | | |
| |||
| 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 | | |
| |||
6108 | 6121 | | |
6109 | 6122 | | |
6110 | 6123 | | |
6111 | | - | |
| 6124 | + | |
6112 | 6125 | | |
6113 | 6126 | | |
6114 | 6127 | | |
| |||
6128 | 6141 | | |
6129 | 6142 | | |
6130 | 6143 | | |
| 6144 | + | |
| 6145 | + | |
| 6146 | + | |
| 6147 | + | |
| 6148 | + | |
| 6149 | + | |
| 6150 | + | |
| 6151 | + | |
| 6152 | + | |
6131 | 6153 | | |
6132 | 6154 | | |
6133 | 6155 | | |
6134 | 6156 | | |
6135 | 6157 | | |
6136 | 6158 | | |
6137 | | - | |
6138 | 6159 | | |
6139 | 6160 | | |
6140 | 6161 | | |
| |||
6149 | 6170 | | |
6150 | 6171 | | |
6151 | 6172 | | |
| 6173 | + | |
6152 | 6174 | | |
6153 | 6175 | | |
6154 | 6176 | | |
| |||
0 commit comments