All of lore.kernel.org
 help / color / mirror / Atom feed
* [BUGFIX PATCH] perf/probe: Fix to clear tev->nargs in clear_probe_trace_event()
@ 2019-09-15 16:44 Masami Hiramatsu
  2019-09-20 18:31 ` Arnaldo Carvalho de Melo
  2019-09-22 10:52 ` [tip: perf/urgent] perf probe: " tip-bot2 for Masami Hiramatsu
  0 siblings, 2 replies; 3+ messages in thread
From: Masami Hiramatsu @ 2019-09-15 16:44 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Wang Nan, Jiri Olsa, Namhyung Kim, Masami Hiramatsu, linux-kernel

Since add_probe_trace_event() can reuse tf->tevs[i] after
calling clear_probe_trace_event(), this can make perf-probe
crash if the 1st attempt of probe event finding fails to find
an event argument, and the 2nd attempt fails to find probe point.

E.g.
  $ perf probe -D "task_pid_nr tsk"
  Failed to find 'tsk' in this function.
  Failed to get entry address of warn_bad_vsyscall
  Segmentation fault (core dumped)


Fixes: 092b1f0b5f9f ("perf probe: Clear probe_trace_event when add_probe_trace_event() fails")
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
---
 tools/perf/util/probe-event.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index b8e0967c5c21..91cab5f669d2 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -2331,6 +2331,7 @@ void clear_probe_trace_event(struct probe_trace_event *tev)
 		}
 	}
 	zfree(&tev->args);
+	tev->nargs = 0;
 }
 
 struct kprobe_blacklist_node {


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [BUGFIX PATCH] perf/probe: Fix to clear tev->nargs in clear_probe_trace_event()
  2019-09-15 16:44 [BUGFIX PATCH] perf/probe: Fix to clear tev->nargs in clear_probe_trace_event() Masami Hiramatsu
@ 2019-09-20 18:31 ` Arnaldo Carvalho de Melo
  2019-09-22 10:52 ` [tip: perf/urgent] perf probe: " tip-bot2 for Masami Hiramatsu
  1 sibling, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2019-09-20 18:31 UTC (permalink / raw)
  To: Masami Hiramatsu; +Cc: Wang Nan, Jiri Olsa, Namhyung Kim, linux-kernel

Em Mon, Sep 16, 2019 at 01:44:40AM +0900, Masami Hiramatsu escreveu:
> Since add_probe_trace_event() can reuse tf->tevs[i] after
> calling clear_probe_trace_event(), this can make perf-probe
> crash if the 1st attempt of probe event finding fails to find
> an event argument, and the 2nd attempt fails to find probe point.
> 
> E.g.
>   $ perf probe -D "task_pid_nr tsk"
>   Failed to find 'tsk' in this function.
>   Failed to get entry address of warn_bad_vsyscall
>   Segmentation fault (core dumped)

Thanks, tested and applied!

- Arnaldo
 
> 
> Fixes: 092b1f0b5f9f ("perf probe: Clear probe_trace_event when add_probe_trace_event() fails")
> Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
> Cc: Wang Nan <wangnan0@huawei.com>
> ---
>  tools/perf/util/probe-event.c |    1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
> index b8e0967c5c21..91cab5f669d2 100644
> --- a/tools/perf/util/probe-event.c
> +++ b/tools/perf/util/probe-event.c
> @@ -2331,6 +2331,7 @@ void clear_probe_trace_event(struct probe_trace_event *tev)
>  		}
>  	}
>  	zfree(&tev->args);
> +	tev->nargs = 0;
>  }
>  
>  struct kprobe_blacklist_node {

-- 

- Arnaldo

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [tip: perf/urgent] perf probe: Fix to clear tev->nargs in clear_probe_trace_event()
  2019-09-15 16:44 [BUGFIX PATCH] perf/probe: Fix to clear tev->nargs in clear_probe_trace_event() Masami Hiramatsu
  2019-09-20 18:31 ` Arnaldo Carvalho de Melo
@ 2019-09-22 10:52 ` tip-bot2 for Masami Hiramatsu
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot2 for Masami Hiramatsu @ 2019-09-22 10:52 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Masami Hiramatsu, Arnaldo Carvalho de Melo, Jiri Olsa,
	Namhyung Kim, Wang Nan, Ingo Molnar, Borislav Petkov,
	linux-kernel

The following commit has been merged into the perf/urgent branch of tip:

Commit-ID:     9e6124d9d635957b56717f85219a88701617253f
Gitweb:        https://git.kernel.org/tip/9e6124d9d635957b56717f85219a88701617253f
Author:        Masami Hiramatsu <mhiramat@kernel.org>
AuthorDate:    Mon, 16 Sep 2019 01:44:40 +09:00
Committer:     Arnaldo Carvalho de Melo <acme@redhat.com>
CommitterDate: Fri, 20 Sep 2019 15:30:09 -03:00

perf probe: Fix to clear tev->nargs in clear_probe_trace_event()

Since add_probe_trace_event() can reuse tf->tevs[i] after calling
clear_probe_trace_event(), this can make perf-probe crash if the 1st
attempt of probe event finding fails to find an event argument, and the
2nd attempt fails to find probe point.

E.g.
  $ perf probe -D "task_pid_nr tsk"
  Failed to find 'tsk' in this function.
  Failed to get entry address of warn_bad_vsyscall
  Segmentation fault (core dumped)

Committer testing:

After the patch:

  $ perf probe -D "task_pid_nr tsk"
  Failed to find 'tsk' in this function.
  Failed to get entry address of warn_bad_vsyscall
  Failed to get entry address of signal_fault
  Failed to get entry address of show_signal
  Failed to get entry address of umip_printk
  Failed to get entry address of __bad_area_nosemaphore
  <SNIP>
  Failed to get entry address of sock_set_timeout
  Failed to get entry address of tcp_recvmsg
  Probe point 'task_pid_nr' not found.
    Error: Failed to add events.
  $

Fixes: 092b1f0b5f9f ("perf probe: Clear probe_trace_event when add_probe_trace_event() fails")
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lore.kernel.org/lkml/156856587999.25775.5145779959474477595.stgit@devnote2
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/probe-event.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index b8e0967..91cab5f 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -2331,6 +2331,7 @@ void clear_probe_trace_event(struct probe_trace_event *tev)
 		}
 	}
 	zfree(&tev->args);
+	tev->nargs = 0;
 }
 
 struct kprobe_blacklist_node {

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-09-22 10:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-15 16:44 [BUGFIX PATCH] perf/probe: Fix to clear tev->nargs in clear_probe_trace_event() Masami Hiramatsu
2019-09-20 18:31 ` Arnaldo Carvalho de Melo
2019-09-22 10:52 ` [tip: perf/urgent] perf probe: " tip-bot2 for Masami Hiramatsu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.