If a function had ever had IPMODIFY or DIRECT attached to it, where this is how live kernel patching and BPF overrides work, mark them and display an "M" in the enabled_functions and touched_functions files. This can be used for debugging. If a function had been modified and later there's a bug in the code related to that function, this can be used to know if the cause is possibly from a live kernel patch or a BPF program that changed the behavior of the code. Also update the documentation on the enabled_functions and touched_functions output, as it was missing direct callers and CALL_OPS. And include this new modify attribute. Link: https://lore.kernel.org/linux-trace-kernel/20230502213233.004e3ae4@gandalf.local.home
Showing the changes to kernel (1 of 3 files). Show all
Unified · Split
| @@ -46,7 +46,8 @@ · 45 unmodified lines | ||
| 46 | 46 | #include "trace_stat.h" |
| 47 | 47 | |
| 48 | 48 | /* Flags that do not get reset */ |
| 49 | −#define FTRACE_NOCLEAR_FLAGS (FTRACE_FL_DISABLED | FTRACE_FL_TOUCHED) | |
| 49 | +#define FTRACE_NOCLEAR_FLAGS (FTRACE_FL_DISABLED | FTRACE_FL_TOUCHED | \ | |
| 50 | + FTRACE_FL_MODIFIED) | |
| 50 | 51 | |
| 51 | 52 | #define FTRACE_INVALID_FUNCTION "__ftrace_invalid_address__" |
| 52 | 53 | |
| @@ -2273,6 +2274,10 @@ static int ftrace_check_record(struct dyn_ftrace *rec, bool enable, bool update) · 2220 unmodified lines | ||
| 2273 | 2274 | rec->flags &= ~FTRACE_FL_TRAMP_EN; |
| 2274 | 2275 | } |
| 2275 | 2276 | |
| 2277 | + /* Keep track of anything that modifies the function */ | |
| 2278 | + if (rec->flags & (FTRACE_FL_DIRECT | FTRACE_FL_IPMODIFY)) | |
| 2279 | + rec->flags |= FTRACE_FL_MODIFIED; | |
| 2280 | + | |
| 2276 | 2281 | if (flag & FTRACE_FL_DIRECT) { |
| 2277 | 2282 | /* |
| 2278 | 2283 | * If there's only one user (direct_ops helper) |
| @@ -3866,12 +3871,13 @@ static int t_show(struct seq_file *m, void *v) · 1587 unmodified lines | ||
| 3866 | 3871 | if (iter->flags & (FTRACE_ITER_ENABLED | FTRACE_ITER_TOUCHED)) { |
| 3867 | 3872 | struct ftrace_ops *ops; |
| 3868 | 3873 | |
| 3869 | − seq_printf(m, " (%ld)%s%s%s%s", | |
| 3874 | + seq_printf(m, " (%ld)%s%s%s%s%s", | |
| 3870 | 3875 | ftrace_rec_count(rec), |
| 3871 | 3876 | rec->flags & FTRACE_FL_REGS ? " R" : " ", |
| 3872 | 3877 | rec->flags & FTRACE_FL_IPMODIFY ? " I" : " ", |
| 3873 | 3878 | rec->flags & FTRACE_FL_DIRECT ? " D" : " ", |
| 3874 | − rec->flags & FTRACE_FL_CALL_OPS ? " O" : " "); | |
| 3879 | + rec->flags & FTRACE_FL_CALL_OPS ? " O" : " ", | |
| 3880 | + rec->flags & FTRACE_FL_MODIFIED ? " M " : " "); | |
| 3875 | 3881 | if (rec->flags & FTRACE_FL_TRAMP_EN) { |
| 3876 | 3882 | ops = ftrace_find_tramp_ops_any(rec); |
| 3877 | 3883 | if (ops) { |