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>
This commit is contained in:
parent
84d7ed799f
commit
4161824f18
1 changed files with 9 additions and 8 deletions
|
@ -552,17 +552,18 @@ static int probe_event_enable(struct trace_uprobe *tu, int flag)
|
||||||
return -EINTR;
|
return -EINTR;
|
||||||
|
|
||||||
utc->cons.handler = uprobe_dispatcher;
|
utc->cons.handler = uprobe_dispatcher;
|
||||||
ret = uprobe_register(tu->inode, tu->offset, &utc->cons);
|
|
||||||
if (ret) {
|
|
||||||
kfree(utc);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
tu->flags |= flag;
|
|
||||||
utc->tu = tu;
|
utc->tu = tu;
|
||||||
tu->consumer = utc;
|
tu->consumer = utc;
|
||||||
|
tu->flags |= flag;
|
||||||
|
|
||||||
return 0;
|
ret = uprobe_register(tu->inode, tu->offset, &utc->cons);
|
||||||
|
if (ret) {
|
||||||
|
tu->consumer = NULL;
|
||||||
|
tu->flags &= ~flag;
|
||||||
|
kfree(utc);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void probe_event_disable(struct trace_uprobe *tu, int flag)
|
static void probe_event_disable(struct trace_uprobe *tu, int flag)
|
||||||
|
|
Loading…
Reference in a new issue