tracing/kprobes: Fix trace_probe flags on enable_trace_kprobe() failure
Subsystems (2)
Steven Rostedt
maintainerPATCH 4/7 tracing/kprobes: Fix trace_probe flags on enable_trace_kprobe() failure
From: Artem Savkov <[email protected]>
If enable_trace_kprobe fails to enable the probe in enable_k(ret)probe it returns an error, but does not unset the tp flags it set previously. This results in a probe being considered enabled and failures like being unable to remove the probe through kprobe_events file since probes_open() expects every probe to be disabled.
Cc Ingo Molnar <[email protected]>
Fixes 41a7dd420c57 ("tracing/kprobes: Support ftrace_event_file base multibuffer")
Acked-by Masami Hiramatsu <[email protected]>
Reviewed-by Josh Poimboeuf <[email protected]>
Signed-off-by Artem Savkov <[email protected]>
Signed-off-by Steven Rostedt (VMware) <[email protected]>
--- kernel/trace/trace_kprobe.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
kernel/trace/trace_kprobe.c +11 -2
@@ -400,11 +400,10 @@ static struct trace_kprobe *find_trace_kprobe(const char *event,static int enable_trace_kprobe (struct trace_kprobe *tk,struct trace_event_file *file) { +struct event_file_link *link;int ret =0 ;if (file) { -struct event_file_link *link; - link =kmalloc (sizeof (*link),GFP_KERNEL );if (!link) { ret = -ENOMEM ;
@@ -424,6 +423,16 @@ enable_trace_kprobe(struct trace_kprobe *tk, struct trace_event_file *file)else ret =enable_kprobe (&tk->rp.kp); } + +if (ret) { +if (file) { +list_del_rcu (&link->list); +kfree (link); + tk->tp.flags &= ~TP_FLAG_TRACE ; + }else { + tk->tp.flags &= ~TP_FLAG_PROFILE ; + } + } out:return ret; }
Signature · 1 line
2.17.1