kernel.ftrace_enabled=0 silently disables ftrace-based kprobes/kretprobes: arming succeeds, the probe stops firing, and re-enabling restores it. Unlike trampolines, they never had this protection. kprobe_ftrace_ops and kprobe_ipmodify_ops are used only by ftrace-based kprobes, so FTRACE_OPS_FL_PERMANENT, as livepatch uses, is safe here. kprobe.multi, kretprobe.multi and kprobe.session (fprobe-based) are not covered: their return path shares the function-graph subops manager with unrelated tracers. Cc: stable@vger.kernel.org Signed-off-by: Andrey Grodzovsky Acked-by: Masami Hiramatsu (Google) Acked-by: Steven Rostedt --- kernel/kprobes.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/kprobes.c b/kernel/kprobes.c index 2441b9e39343..6e87c90b9835 100644 --- a/kernel/kprobes.c +++ b/kernel/kprobes.c @@ -1365,14 +1365,15 @@ static struct kprobe *alloc_aggr_kprobe(struct kprobe *p) #endif /* CONFIG_OPTPROBES */ #ifdef CONFIG_KPROBES_ON_FTRACE +/* Same protection livepatch gives its own ftrace_ops. */ static struct ftrace_ops kprobe_ftrace_ops __read_mostly = { .func = kprobe_ftrace_handler, - .flags = FTRACE_OPS_FL_SAVE_REGS, + .flags = FTRACE_OPS_FL_SAVE_REGS | FTRACE_OPS_FL_PERMANENT, }; static struct ftrace_ops kprobe_ipmodify_ops __read_mostly = { .func = kprobe_ftrace_handler, - .flags = FTRACE_OPS_FL_SAVE_REGS | FTRACE_OPS_FL_IPMODIFY, + .flags = FTRACE_OPS_FL_SAVE_REGS | FTRACE_OPS_FL_IPMODIFY | FTRACE_OPS_FL_PERMANENT, }; static int kprobe_ipmodify_enabled; -- 2.34.1