* [PATCH v2] tracing/kprobes: Fix trace_probe flags on enable_trace_kprobe() failure
@ 2018-07-25 14:20 Artem Savkov
2018-07-25 14:30 ` Steven Rostedt
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Artem Savkov @ 2018-07-25 14:20 UTC (permalink / raw)
To: Steven Rostedt, Masami Hiramatsu
Cc: Ingo Molnar, linux-kernel, Josh Poimboeuf, Artem Savkov
If enable_trace_kprobe fails to enable the probe in enable_k(ret)probe
it returns an error, but does not unset the tp flags it set previously.
This results in a probe being considered enabled and failures like being
unable to remove the probe through kprobe_events file since probes_open()
expects every probe to be disabled.
Signed-off-by: Artem Savkov <asavkov@redhat.com>
---
kernel/trace/trace_kprobe.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index 21f718472942..27ace4513c43 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -400,11 +400,10 @@ static struct trace_kprobe *find_trace_kprobe(const char *event,
static int
enable_trace_kprobe(struct trace_kprobe *tk, struct trace_event_file *file)
{
+ struct event_file_link *link;
int ret = 0;
if (file) {
- struct event_file_link *link;
-
link = kmalloc(sizeof(*link), GFP_KERNEL);
if (!link) {
ret = -ENOMEM;
@@ -424,6 +423,16 @@ enable_trace_kprobe(struct trace_kprobe *tk, struct trace_event_file *file)
else
ret = enable_kprobe(&tk->rp.kp);
}
+
+ if (ret) {
+ if (file) {
+ list_del_rcu(&link->list);
+ kfree(link);
+ tk->tp.flags &= ~TP_FLAG_TRACE;
+ } else {
+ tk->tp.flags &= ~TP_FLAG_PROFILE;
+ }
+ }
out:
return ret;
}
--
2.13.6
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2] tracing/kprobes: Fix trace_probe flags on enable_trace_kprobe() failure
2018-07-25 14:20 [PATCH v2] tracing/kprobes: Fix trace_probe flags on enable_trace_kprobe() failure Artem Savkov
@ 2018-07-25 14:30 ` Steven Rostedt
2018-07-25 15:35 ` Josh Poimboeuf
2018-07-25 15:41 ` Masami Hiramatsu
2 siblings, 0 replies; 6+ messages in thread
From: Steven Rostedt @ 2018-07-25 14:30 UTC (permalink / raw)
To: Masami Hiramatsu; +Cc: Artem Savkov, Ingo Molnar, linux-kernel, Josh Poimboeuf
On Wed, 25 Jul 2018 16:20:38 +0200
Artem Savkov <asavkov@redhat.com> wrote:
> If enable_trace_kprobe fails to enable the probe in enable_k(ret)probe
> it returns an error, but does not unset the tp flags it set previously.
> This results in a probe being considered enabled and failures like being
> unable to remove the probe through kprobe_events file since probes_open()
> expects every probe to be disabled.
>
> Signed-off-by: Artem Savkov <asavkov@redhat.com>
Masami,
Can you ack this?
Thanks!
-- Steve
> ---
> kernel/trace/trace_kprobe.c | 13 +++++++++++--
> 1 file changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
> index 21f718472942..27ace4513c43 100644
> --- a/kernel/trace/trace_kprobe.c
> +++ b/kernel/trace/trace_kprobe.c
> @@ -400,11 +400,10 @@ static struct trace_kprobe *find_trace_kprobe(const char *event,
> static int
> enable_trace_kprobe(struct trace_kprobe *tk, struct trace_event_file *file)
> {
> + struct event_file_link *link;
> int ret = 0;
>
> if (file) {
> - struct event_file_link *link;
> -
> link = kmalloc(sizeof(*link), GFP_KERNEL);
> if (!link) {
> ret = -ENOMEM;
> @@ -424,6 +423,16 @@ enable_trace_kprobe(struct trace_kprobe *tk, struct trace_event_file *file)
> else
> ret = enable_kprobe(&tk->rp.kp);
> }
> +
> + if (ret) {
> + if (file) {
> + list_del_rcu(&link->list);
> + kfree(link);
> + tk->tp.flags &= ~TP_FLAG_TRACE;
> + } else {
> + tk->tp.flags &= ~TP_FLAG_PROFILE;
> + }
> + }
> out:
> return ret;
> }
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] tracing/kprobes: Fix trace_probe flags on enable_trace_kprobe() failure
2018-07-25 14:20 [PATCH v2] tracing/kprobes: Fix trace_probe flags on enable_trace_kprobe() failure Artem Savkov
2018-07-25 14:30 ` Steven Rostedt
@ 2018-07-25 15:35 ` Josh Poimboeuf
2018-07-25 15:43 ` Steven Rostedt
2018-07-25 15:41 ` Masami Hiramatsu
2 siblings, 1 reply; 6+ messages in thread
From: Josh Poimboeuf @ 2018-07-25 15:35 UTC (permalink / raw)
To: Artem Savkov; +Cc: Steven Rostedt, Masami Hiramatsu, Ingo Molnar, linux-kernel
On Wed, Jul 25, 2018 at 04:20:38PM +0200, Artem Savkov wrote:
> If enable_trace_kprobe fails to enable the probe in enable_k(ret)probe
> it returns an error, but does not unset the tp flags it set previously.
> This results in a probe being considered enabled and failures like being
> unable to remove the probe through kprobe_events file since probes_open()
> expects every probe to be disabled.
>
> Signed-off-by: Artem Savkov <asavkov@redhat.com>
Reviewed-by: Josh Poimboeuf <jpoimboe@redhat.com>
--
Josh
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] tracing/kprobes: Fix trace_probe flags on enable_trace_kprobe() failure
2018-07-25 14:20 [PATCH v2] tracing/kprobes: Fix trace_probe flags on enable_trace_kprobe() failure Artem Savkov
2018-07-25 14:30 ` Steven Rostedt
2018-07-25 15:35 ` Josh Poimboeuf
@ 2018-07-25 15:41 ` Masami Hiramatsu
2018-07-25 15:42 ` Steven Rostedt
2 siblings, 1 reply; 6+ messages in thread
From: Masami Hiramatsu @ 2018-07-25 15:41 UTC (permalink / raw)
To: Artem Savkov; +Cc: Steven Rostedt, Ingo Molnar, linux-kernel, Josh Poimboeuf
On Wed, 25 Jul 2018 16:20:38 +0200
Artem Savkov <asavkov@redhat.com> wrote:
> If enable_trace_kprobe fails to enable the probe in enable_k(ret)probe
> it returns an error, but does not unset the tp flags it set previously.
> This results in a probe being considered enabled and failures like being
> unable to remove the probe through kprobe_events file since probes_open()
> expects every probe to be disabled.
>
Looks good to me.
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Thanks!
> Signed-off-by: Artem Savkov <asavkov@redhat.com>
> ---
> kernel/trace/trace_kprobe.c | 13 +++++++++++--
> 1 file changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
> index 21f718472942..27ace4513c43 100644
> --- a/kernel/trace/trace_kprobe.c
> +++ b/kernel/trace/trace_kprobe.c
> @@ -400,11 +400,10 @@ static struct trace_kprobe *find_trace_kprobe(const char *event,
> static int
> enable_trace_kprobe(struct trace_kprobe *tk, struct trace_event_file *file)
> {
> + struct event_file_link *link;
> int ret = 0;
>
> if (file) {
> - struct event_file_link *link;
> -
> link = kmalloc(sizeof(*link), GFP_KERNEL);
> if (!link) {
> ret = -ENOMEM;
> @@ -424,6 +423,16 @@ enable_trace_kprobe(struct trace_kprobe *tk, struct trace_event_file *file)
> else
> ret = enable_kprobe(&tk->rp.kp);
> }
> +
> + if (ret) {
> + if (file) {
> + list_del_rcu(&link->list);
> + kfree(link);
> + tk->tp.flags &= ~TP_FLAG_TRACE;
> + } else {
> + tk->tp.flags &= ~TP_FLAG_PROFILE;
> + }
> + }
> out:
> return ret;
> }
> --
> 2.13.6
>
--
Masami Hiramatsu <mhiramat@kernel.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] tracing/kprobes: Fix trace_probe flags on enable_trace_kprobe() failure
2018-07-25 15:41 ` Masami Hiramatsu
@ 2018-07-25 15:42 ` Steven Rostedt
0 siblings, 0 replies; 6+ messages in thread
From: Steven Rostedt @ 2018-07-25 15:42 UTC (permalink / raw)
To: Masami Hiramatsu; +Cc: Artem Savkov, Ingo Molnar, linux-kernel, Josh Poimboeuf
On Thu, 26 Jul 2018 00:41:13 +0900
Masami Hiramatsu <mhiramat@kernel.org> wrote:
> On Wed, 25 Jul 2018 16:20:38 +0200
> Artem Savkov <asavkov@redhat.com> wrote:
>
> > If enable_trace_kprobe fails to enable the probe in enable_k(ret)probe
> > it returns an error, but does not unset the tp flags it set previously.
> > This results in a probe being considered enabled and failures like being
> > unable to remove the probe through kprobe_events file since probes_open()
> > expects every probe to be disabled.
> >
>
> Looks good to me.
>
> Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Thanks Masami,
-- Steve
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] tracing/kprobes: Fix trace_probe flags on enable_trace_kprobe() failure
2018-07-25 15:35 ` Josh Poimboeuf
@ 2018-07-25 15:43 ` Steven Rostedt
0 siblings, 0 replies; 6+ messages in thread
From: Steven Rostedt @ 2018-07-25 15:43 UTC (permalink / raw)
To: Josh Poimboeuf; +Cc: Artem Savkov, Masami Hiramatsu, Ingo Molnar, linux-kernel
On Wed, 25 Jul 2018 10:35:57 -0500
Josh Poimboeuf <jpoimboe@redhat.com> wrote:
> On Wed, Jul 25, 2018 at 04:20:38PM +0200, Artem Savkov wrote:
> > If enable_trace_kprobe fails to enable the probe in enable_k(ret)probe
> > it returns an error, but does not unset the tp flags it set previously.
> > This results in a probe being considered enabled and failures like being
> > unable to remove the probe through kprobe_events file since probes_open()
> > expects every probe to be disabled.
> >
> > Signed-off-by: Artem Savkov <asavkov@redhat.com>
>
> Reviewed-by: Josh Poimboeuf <jpoimboe@redhat.com>
>
Thanks Josh!
Queued up and currently being tested.
-- Steve
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-07-25 15:43 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-25 14:20 [PATCH v2] tracing/kprobes: Fix trace_probe flags on enable_trace_kprobe() failure Artem Savkov
2018-07-25 14:30 ` Steven Rostedt
2018-07-25 15:35 ` Josh Poimboeuf
2018-07-25 15:43 ` Steven Rostedt
2018-07-25 15:41 ` Masami Hiramatsu
2018-07-25 15:42 ` Steven Rostedt
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).