Skip to content

Commit 547cd9e

Browse files
mhiramatrostedt
authored andcommitted
tracing/uprobes: Add busy check when cleanup all uprobes
Add a busy check loop in cleanup_all_probes() before trying to remove all events in uprobe_events, the same way that kprobe_events does. Without this change, writing null to uprobe_events will try to remove events but if one of them is enabled, it will stop there leaving some events cleared and others not clceared. With this change, writing null to uprobe_events makes sure all events are not enabled before removing events. So, it clears all events, or returns an error (-EBUSY) with keeping all events. Link: http://lkml.kernel.org/r/154140841557.17322.12653952888762532401.stgit@devbox Reviewed-by: Tom Zanussi <tom.zanussi@linux.intel.com> Tested-by: Tom Zanussi <tom.zanussi@linux.intel.com> Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
1 parent a7b1d74 commit 547cd9e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

kernel/trace/trace_uprobe.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,12 +587,19 @@ static int cleanup_all_probes(void)
587587
int ret = 0;
588588

589589
mutex_lock(&uprobe_lock);
590+
/* Ensure no probe is in use. */
591+
list_for_each_entry(tu, &uprobe_list, list)
592+
if (trace_probe_is_enabled(&tu->tp)) {
593+
ret = -EBUSY;
594+
goto end;
595+
}
590596
while (!list_empty(&uprobe_list)) {
591597
tu = list_entry(uprobe_list.next, struct trace_uprobe, list);
592598
ret = unregister_trace_uprobe(tu);
593599
if (ret)
594600
break;
595601
}
602+
end:
596603
mutex_unlock(&uprobe_lock);
597604
return ret;
598605
}

0 commit comments

Comments
 (0)