From: Steven Rostedt <rostedt@goodmis.org>
To: Oleg Nesterov <oleg@redhat.com>
Cc: Ingo Molnar <mingo@elte.hu>,
Ananth N Mavinakayanahalli <ananth@in.ibm.com>,
Anton Arapov <aarapov@redhat.com>,
David Long <dave.long@linaro.org>,
Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>,
Srikar Dronamraju <srikar@linux.vnet.ibm.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/1] uprobes/tracing: uprobe_perf_open() forgets to handle the error from uprobe_apply()
Date: Wed, 23 Apr 2014 23:17:28 -0400 [thread overview]
Message-ID: <20140423231728.1b95e37c@gandalf.local.home> (raw)
In-Reply-To: <20140423165830.GA29493@redhat.com>
On Wed, 23 Apr 2014 18:58:30 +0200
Oleg Nesterov <oleg@redhat.com> wrote:
> uprobe_perf_open()->uprobe_apply() can fail, but this error is wrongly
> ignored. Change uprobe_perf_open() to do uprobe_perf_close() and return
> the error code in this case.
>
> Change uprobe_perf_close() to propogate the error from uprobe_apply()
> as well, although it should not fail.
>
> The patch looks more complicated because it moves uprobe_perf_close()
> up to make it visible to uprobe_perf_open().
>
> Signed-off-by: Oleg Nesterov <oleg@redhat.com>
> ---
> kernel/trace/trace_uprobe.c | 46 +++++++++++++++++++++++-------------------
> 1 files changed, 25 insertions(+), 21 deletions(-)
>
> diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
> index 930e514..9aad3e2 100644
> --- a/kernel/trace/trace_uprobe.c
> +++ b/kernel/trace/trace_uprobe.c
> @@ -1003,56 +1003,60 @@ uprobe_filter_event(struct trace_uprobe *tu, struct perf_event *event)
> return __uprobe_perf_filter(&tu->filter, event->hw.tp_target->mm);
> }
>
> -static int uprobe_perf_open(struct trace_uprobe *tu, struct perf_event *event)
> +static int uprobe_perf_close(struct trace_uprobe *tu, struct perf_event *event)
Egad, this confused the heck out of me. I didn't notice the swap in
functions and was wondering what you were doing. I didn't realize this
is what you meant by moving the uprobe_perf_close() up. I was thinking
you moved the call up or something, not the function itself physically
in the file.
/me tries to continue dazed and confused.
> {
> bool done;
>
> write_lock(&tu->filter.rwlock);
> if (event->hw.tp_target) {
> - /*
> - * event->parent != NULL means copy_process(), we can avoid
> - * uprobe_apply(). current->mm must be probed and we can rely
> - * on dup_mmap() which preserves the already installed bp's.
> - *
> - * attr.enable_on_exec means that exec/mmap will install the
> - * breakpoints we need.
> - */
> + list_del(&event->hw.tp_list);
> done = tu->filter.nr_systemwide ||
> - event->parent || event->attr.enable_on_exec ||
> + (event->hw.tp_target->flags & PF_EXITING) ||
> uprobe_filter_event(tu, event);
> - list_add(&event->hw.tp_list, &tu->filter.perf_events);
> } else {
> + tu->filter.nr_systemwide--;
> done = tu->filter.nr_systemwide;
> - tu->filter.nr_systemwide++;
> }
> write_unlock(&tu->filter.rwlock);
>
> if (!done)
> - uprobe_apply(tu->inode, tu->offset, &tu->consumer, true);
> + return uprobe_apply(tu->inode, tu->offset, &tu->consumer, false);
>
> return 0;
> }
>
> -static int uprobe_perf_close(struct trace_uprobe *tu, struct perf_event *event)
> +static int uprobe_perf_open(struct trace_uprobe *tu, struct perf_event *event)
> {
> bool done;
> + int err;
>
> write_lock(&tu->filter.rwlock);
> if (event->hw.tp_target) {
> - list_del(&event->hw.tp_list);
> + /*
> + * event->parent != NULL means copy_process(), we can avoid
> + * uprobe_apply(). current->mm must be probed and we can rely
> + * on dup_mmap() which preserves the already installed bp's.
> + *
> + * attr.enable_on_exec means that exec/mmap will install the
> + * breakpoints we need.
> + */
> done = tu->filter.nr_systemwide ||
> - (event->hw.tp_target->flags & PF_EXITING) ||
> + event->parent || event->attr.enable_on_exec ||
> uprobe_filter_event(tu, event);
> + list_add(&event->hw.tp_list, &tu->filter.perf_events);
> } else {
> - tu->filter.nr_systemwide--;
> done = tu->filter.nr_systemwide;
> + tu->filter.nr_systemwide++;
> }
> write_unlock(&tu->filter.rwlock);
>
> - if (!done)
> - uprobe_apply(tu->inode, tu->offset, &tu->consumer, false);
> -
> - return 0;
> + err = 0;
> + if (!done) {
> + err = uprobe_apply(tu->inode, tu->offset, &tu->consumer, true);
> + if (err)
> + uprobe_perf_close(tu, event);
> + }
> + return err;
You can add by Acked-by, but next time, please make this into two
patches. One to do the move, the other to do the change.
Thanks!
-- Steve
> }
>
> static bool uprobe_perf_filter(struct uprobe_consumer *uc,
next prev parent reply other threads:[~2014-04-24 3:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-23 16:58 [PATCH 0/1] " Oleg Nesterov
2014-04-23 16:58 ` [PATCH 1/1] " Oleg Nesterov
2014-04-24 3:17 ` Steven Rostedt [this message]
2014-04-24 11:54 ` [PATCH v2 0/2] uprobes/tracing: uprobe_perf_open()->uprobe_apply() fix Oleg Nesterov
2014-04-24 11:55 ` [PATCH v2 1/2] uprobes/tracing: Make uprobe_perf_close() visible to uprobe_perf_open() Oleg Nesterov
2014-04-24 11:55 ` [PATCH v2 2/2] uprobes/tracing: Fix uprobe_perf_open() on uprobe_apply() failure Oleg Nesterov
2014-04-24 12:37 ` [PATCH v2 0/2] uprobes/tracing: uprobe_perf_open()->uprobe_apply() fix Steven Rostedt
2014-04-24 9:03 ` [PATCH 1/1] uprobes/tracing: uprobe_perf_open() forgets to handle the error from uprobe_apply() Srikar Dronamraju
2014-04-24 12:27 ` Oleg Nesterov
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=20140423231728.1b95e37c@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=aarapov@redhat.com \
--cc=ananth@in.ibm.com \
--cc=dave.long@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=masami.hiramatsu.pt@hitachi.com \
--cc=mingo@elte.hu \
--cc=oleg@redhat.com \
--cc=srikar@linux.vnet.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
all inboxes | Powered by JetHome®