From: Sandipan Das <sandipan@linux.vnet.ibm.com>
To: acme@kernel.org, jolsa@redhat.com
Cc: linux-kernel@vger.kernel.org, naveen.n.rao@linux.vnet.ibm.com,
ravi.bangoria@linux.vnet.ibm.com, sukadev@linux.vnet.ibm.com,
maynard@us.ibm.com
Subject: [PATCH v2 2/3] perf tools powerpc: Fix crash if callchain is empty
Date: Wed, 18 Apr 2018 16:28:59 +0530 [thread overview]
Message-ID: <20180418105900.5899-3-sandipan@linux.vnet.ibm.com> (raw)
In-Reply-To: <20180418105900.5899-1-sandipan@linux.vnet.ibm.com>
For some cases, the callchain provided by the kernel may be
empty. So, the callchain ip filtering code will cause a crash
if we do not check whether the struct ip_callchain pointer is
NULL before accessing any members.
This can be observed on a powerpc64le system running Fedora 27
as shown below.
# perf record -b -e cycles:u ls
# perf report --branch-history
perf: Segmentation fault
-------- backtrace --------
perf[0x1027615c]
linux-vdso64.so.1(__kernel_sigtramp_rt64+0x0)[0x7fff856304d8]
perf(arch_skip_callchain_idx+0x44)[0x10257c58]
perf[0x1017f2e4]
perf(thread__resolve_callchain+0x124)[0x1017ff5c]
perf(sample__resolve_callchain+0xf0)[0x10172788]
...
Reported-by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
Signed-off-by: Sandipan Das <sandipan@linux.vnet.ibm.com>
---
tools/perf/arch/powerpc/util/skip-callchain-idx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/arch/powerpc/util/skip-callchain-idx.c b/tools/perf/arch/powerpc/util/skip-callchain-idx.c
index d3a13f79d3ee..910db8762120 100644
--- a/tools/perf/arch/powerpc/util/skip-callchain-idx.c
+++ b/tools/perf/arch/powerpc/util/skip-callchain-idx.c
@@ -262,7 +262,7 @@ int arch_skip_callchain_idx(struct thread *thread, struct ip_callchain *chain)
int rc;
u64 skip_slot = -1;
- if (chain->nr < 3)
+ if (!chain || chain->nr < 3)
return skip_slot;
rc = check_return_addr(thread, chain->ips[1]);
--
2.14.3
next prev parent reply other threads:[~2018-04-18 10:59 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-18 10:58 [PATCH v2 0/3] perf: Fixes for callchain ip handling on powerpc Sandipan Das
2018-04-18 10:58 ` [PATCH v2 1/3] perf tools powerpc: Fix callchain ip filtering Sandipan Das
2018-04-18 10:58 ` Sandipan Das [this message]
2018-04-18 10:59 ` [PATCH v2 3/3] perf tests: Fix record+probe_libc_inet_pton.sh for powerpc64 Sandipan Das
2018-04-18 17:53 ` [PATCH v2 0/3] perf: Fixes for callchain ip handling on powerpc Arnaldo Carvalho de Melo
2018-04-19 6:01 ` Ravi Bangoria
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=20180418105900.5899-3-sandipan@linux.vnet.ibm.com \
--to=sandipan@linux.vnet.ibm.com \
--cc=acme@kernel.org \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maynard@us.ibm.com \
--cc=naveen.n.rao@linux.vnet.ibm.com \
--cc=ravi.bangoria@linux.vnet.ibm.com \
--cc=sukadev@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
Powered by JetHome