linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf callchain: Fix segfault in thread__resolve_callchain_sample()
@ 2019-11-14 14:25 Adrian Hunter
  2019-11-14 19:13 ` Arnaldo Carvalho de Melo
  2019-11-19 16:56 ` [tip: perf/core] " tip-bot2 for Adrian Hunter
  0 siblings, 2 replies; 3+ messages in thread
From: Adrian Hunter @ 2019-11-14 14:25 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo; +Cc: Jiri Olsa, linux-kernel

Do not dereference 'chain' when it is NULL.

  $ perf record -e intel_pt//u -e branch-misses:u uname
  $ perf report --itrace=l --branch-history
  perf: Segmentation fault

Fixes: e9024d519d89 ("perf callchain: Honour the ordering of PERF_CONTEXT_{USER,KERNEL,etc}")
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 tools/perf/util/machine.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 6a0f5c25ce3e..0a21ab69a247 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -2414,7 +2414,7 @@ static int thread__resolve_callchain_sample(struct thread *thread,
 	}
 
 check_calls:
-	if (callchain_param.order != ORDER_CALLEE) {
+	if (chain && callchain_param.order != ORDER_CALLEE) {
 		err = find_prev_cpumode(chain, thread, cursor, parent, root_al,
 					&cpumode, chain->nr - first_call);
 		if (err)
-- 
2.17.1


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

* Re: [PATCH] perf callchain: Fix segfault in thread__resolve_callchain_sample()
  2019-11-14 14:25 [PATCH] perf callchain: Fix segfault in thread__resolve_callchain_sample() Adrian Hunter
@ 2019-11-14 19:13 ` Arnaldo Carvalho de Melo
  2019-11-19 16:56 ` [tip: perf/core] " tip-bot2 for Adrian Hunter
  1 sibling, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2019-11-14 19:13 UTC (permalink / raw)
  To: Adrian Hunter; +Cc: Jiri Olsa, linux-kernel

Em Thu, Nov 14, 2019 at 04:25:38PM +0200, Adrian Hunter escreveu:
> Do not dereference 'chain' when it is NULL.
> 
>   $ perf record -e intel_pt//u -e branch-misses:u uname
>   $ perf report --itrace=l --branch-history
>   perf: Segmentation fault

Thanks, tested and applied.

- Arnaldo
 
> Fixes: e9024d519d89 ("perf callchain: Honour the ordering of PERF_CONTEXT_{USER,KERNEL,etc}")
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
> ---
>  tools/perf/util/machine.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
> index 6a0f5c25ce3e..0a21ab69a247 100644
> --- a/tools/perf/util/machine.c
> +++ b/tools/perf/util/machine.c
> @@ -2414,7 +2414,7 @@ static int thread__resolve_callchain_sample(struct thread *thread,
>  	}
>  
>  check_calls:
> -	if (callchain_param.order != ORDER_CALLEE) {
> +	if (chain && callchain_param.order != ORDER_CALLEE) {
>  		err = find_prev_cpumode(chain, thread, cursor, parent, root_al,
>  					&cpumode, chain->nr - first_call);
>  		if (err)
> -- 
> 2.17.1

-- 

- Arnaldo

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

* [tip: perf/core] perf callchain: Fix segfault in thread__resolve_callchain_sample()
  2019-11-14 14:25 [PATCH] perf callchain: Fix segfault in thread__resolve_callchain_sample() Adrian Hunter
  2019-11-14 19:13 ` Arnaldo Carvalho de Melo
@ 2019-11-19 16:56 ` tip-bot2 for Adrian Hunter
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot2 for Adrian Hunter @ 2019-11-19 16:56 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Adrian Hunter, Arnaldo Carvalho de Melo, Jiri Olsa, Ingo Molnar,
	Borislav Petkov, linux-kernel

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

Commit-ID:     aceb98261ea7d9fe38f9c140c5531f0b13623832
Gitweb:        https://git.kernel.org/tip/aceb98261ea7d9fe38f9c140c5531f0b13623832
Author:        Adrian Hunter <adrian.hunter@intel.com>
AuthorDate:    Thu, 14 Nov 2019 16:25:38 +02:00
Committer:     Arnaldo Carvalho de Melo <acme@redhat.com>
CommitterDate: Mon, 18 Nov 2019 13:01:59 -03:00

perf callchain: Fix segfault in thread__resolve_callchain_sample()

Do not dereference 'chain' when it is NULL.

  $ perf record -e intel_pt//u -e branch-misses:u uname
  $ perf report --itrace=l --branch-history
  perf: Segmentation fault

Fixes: e9024d519d89 ("perf callchain: Honour the ordering of PERF_CONTEXT_{USER,KERNEL,etc}")
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lore.kernel.org/lkml/20191114142538.4097-1-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/machine.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 7d2e211..71ee078 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -2385,7 +2385,7 @@ static int thread__resolve_callchain_sample(struct thread *thread,
 	}
 
 check_calls:
-	if (callchain_param.order != ORDER_CALLEE) {
+	if (chain && callchain_param.order != ORDER_CALLEE) {
 		err = find_prev_cpumode(chain, thread, cursor, parent, root_al,
 					&cpumode, chain->nr - first_call);
 		if (err)

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

end of thread, other threads:[~2019-11-19 16:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-14 14:25 [PATCH] perf callchain: Fix segfault in thread__resolve_callchain_sample() Adrian Hunter
2019-11-14 19:13 ` Arnaldo Carvalho de Melo
2019-11-19 16:56 ` [tip: perf/core] " tip-bot2 for Adrian Hunter

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).