From: Oleg Nesterov <oleg@redhat.com>
To: Ingo Molnar <mingo@elte.hu>,
Srikar Dronamraju <srikar@linux.vnet.ibm.com>,
Steven Rostedt <rostedt@goodmis.org>
Cc: Anton Arapov <anton@redhat.com>, Frank Eigler <fche@redhat.com>,
Josh Stone <jistone@redhat.com>,
Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>,
"Suzuki K. Poulose" <suzuki@in.ibm.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH 2/6] uprobes/tracing: Fully initialize uprobe_trace_consumer before uprobe_register()
Date: Thu, 31 Jan 2013 20:18:19 +0100 [thread overview]
Message-ID: <20130131191819.GA30437@redhat.com> (raw)
In-Reply-To: <20130131191752.GA30410@redhat.com>
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>
---
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 6563f00..7b75949 100644
--- a/kernel/trace/trace_uprobe.c
+++ b/kernel/trace/trace_uprobe.c
@@ -547,17 +547,18 @@ static int probe_event_enable(struct trace_uprobe *tu, int flag)
return -EINTR;
utc->cons.handler = uprobe_dispatcher;
+ utc->tu = tu;
+ tu->consumer = utc;
+ tu->flags |= flag;
+
ret = uprobe_register(tu->inode, tu->offset, &utc->cons);
if (ret) {
+ tu->consumer = NULL;
+ tu->flags &= ~flag;
kfree(utc);
- return ret;
}
- tu->flags |= flag;
- utc->tu = tu;
- tu->consumer = utc;
-
- return 0;
+ return ret;
}
static void probe_event_disable(struct trace_uprobe *tu, int flag)
--
1.5.5.1
next prev parent reply other threads:[~2013-01-31 19:22 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-31 19:17 [PATCH 0/6] uprobes/tracing: cleanups and minor fixes Oleg Nesterov
2013-01-31 19:18 ` [PATCH 1/6] uprobes/tracing: Fix dentry/mount leak in create_trace_uprobe() Oleg Nesterov
2013-01-31 19:18 ` Oleg Nesterov [this message]
2013-01-31 19:18 ` [PATCH 3/6] uprobes/tracing: Ensure inode != NULL " Oleg Nesterov
2013-02-04 10:48 ` Srikar Dronamraju
2013-01-31 19:18 ` [PATCH 4/6] uprobes/tracing: Introduce is_trace_uprobe_enabled() Oleg Nesterov
2013-02-04 16:12 ` Srikar Dronamraju
2013-01-31 19:18 ` [PATCH 5/6] uprobes/tracing: Kill uprobe_trace_consumer, embed uprobe_consumer into trace_uprobe Oleg Nesterov
2013-02-04 16:59 ` Srikar Dronamraju
2013-02-04 17:20 ` Oleg Nesterov
2013-02-11 9:18 ` Srikar Dronamraju
2013-02-11 9:19 ` Srikar Dronamraju
2013-01-31 19:18 ` [PATCH 6/6] uprobes/perf: Always increment trace_uprobe->nhit Oleg Nesterov
2013-02-04 11:17 ` Srikar Dronamraju
2013-02-04 15:18 ` Oleg Nesterov
2013-02-04 16:26 ` Srikar Dronamraju
2013-02-04 16:34 ` Steven Rostedt
2013-02-11 9:19 ` Srikar Dronamraju
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130131191819.GA30437@redhat.com \
--to=oleg@redhat.com \
--cc=anton@redhat.com \
--cc=fche@redhat.com \
--cc=jistone@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=masami.hiramatsu.pt@hitachi.com \
--cc=mingo@elte.hu \
--cc=rostedt@goodmis.org \
--cc=srikar@linux.vnet.ibm.com \
--cc=suzuki@in.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).