diff options
author | Oleg Nesterov <oleg@redhat.com> | 2013-01-27 12:36:24 -0500 |
---|---|---|
committer | Oleg Nesterov <oleg@redhat.com> | 2013-02-08 12:10:19 -0500 |
commit | 4161824f18ff4f56f46595a4016c7315dd0d24f1 (patch) | |
tree | 0543311b70f8855f967fb41c3d7c3bf61c0c8a09 /kernel/trace/trace_uprobe.c | |
parent | 84d7ed799fd6c1366547d88ddb8188c65de3b94f (diff) |
uprobes/tracing: Fully initialize uprobe_trace_consumer before uprobe_register()
probe_event_enable() does uprobe_register() and only after that sets
utc->tu and tu->consumer/flags. This can race with uprobe_dispatcher()
which can miss these assignments or see them out of order. Nothing
really bad can happen, but this doesn't look clean/safe.
And this does not allow to use uprobe_consumer->filter() we are going
to add, it is called by uprobe_register() and it needs utc->tu.
Change this code to initialize everything before uprobe_register(), and
reset tu->consumer/flags if it fails. We can't race with event_disable(),
the caller holds event_mutex, and if we could the code would be wrong
anyway.
In fact I think uprobe_trace_consumer should die, it buys nothing but
complicates the code. We can simply add uprobe_consumer into trace_uprobe.
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Diffstat (limited to 'kernel/trace/trace_uprobe.c')
-rw-r--r-- | kernel/trace/trace_uprobe.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c index 06c22bad776a..15b8eceeddc5 100644 --- a/kernel/trace/trace_uprobe.c +++ b/kernel/trace/trace_uprobe.c | |||
@@ -552,17 +552,18 @@ static int probe_event_enable(struct trace_uprobe *tu, int flag) | |||
552 | return -EINTR; | 552 | return -EINTR; |
553 | 553 | ||
554 | utc->cons.handler = uprobe_dispatcher; | 554 | utc->cons.handler = uprobe_dispatcher; |
555 | utc->tu = tu; | ||
556 | tu->consumer = utc; | ||
557 | tu->flags |= flag; | ||
558 | |||
555 | ret = uprobe_register(tu->inode, tu->offset, &utc->cons); | 559 | ret = uprobe_register(tu->inode, tu->offset, &utc->cons); |
556 | if (ret) { | 560 | if (ret) { |
561 | tu->consumer = NULL; | ||
562 | tu->flags &= ~flag; | ||
557 | kfree(utc); | 563 | kfree(utc); |
558 | return ret; | ||
559 | } | 564 | } |
560 | 565 | ||
561 | tu->flags |= flag; | 566 | return ret; |
562 | utc->tu = tu; | ||
563 | tu->consumer = utc; | ||
564 | |||
565 | return 0; | ||
566 | } | 567 | } |
567 | 568 | ||
568 | static void probe_event_disable(struct trace_uprobe *tu, int flag) | 569 | static void probe_event_disable(struct trace_uprobe *tu, int flag) |