mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: <lv.yating@zte.com.cn>
To: <peterz@infradead.org>, <mingo@redhat.com>, <acme@kernel.org>,
	<namhyung@kernel.org>, <mark.rutland@arm.com>,
	<alexander.shishkin@linux.intel.com>, <jolsa@kernel.org>,
	<irogers@google.com>, <adrian.hunter@intel.com>,
	<james.clark@linaro.org>
Cc: <linux-perf-users@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <liu.qingtao2@zte.com.cn>,
	<he.yilin@zte.com.cn>, <zhang.cheng35@zte.com.cn>,
	<ye.zhihao1@zte.com.cn>, <shen.lin1@zte.com.cn>,
	<dai.hualiang@zte.com.cn>, <stable@vger.kernel.org>,
	<hu.shengming@zte.com.cn>
Subject: [PATCH] perf machine: Fix NULL deref in thread__resolve_callchain_sample()
Date: Tue, 27 Oct 2026 19:47:32 +0800 (CST)	[thread overview]
Message-ID: <202610271154.69RBsOlq045164@mse-fl2.zte.com.cn> (raw)

From: lvyating <lv.yating@zte.com.cn>

When recording with -j stack, resolve_lbr_callchain_sample() can
dereference a NULL 'chain' pointer while resolving the branch
stack.

$ perf record -j stack -e branches:u uname
perf: Segmentation fault

Fix it by checking 'chain' for NULL before dereferencing it.

Fixes: 29be60c93d2d ("perf build-id: Mark DSO in sample callchains")
Signed-off-by: lvyating <lv.yating@zte.com.cn>
Cc: stable@vger.kernel.org
---
 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 f86b3b7df742..10a88c070814 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -2858,7 +2858,7 @@ static int thread__resolve_callchain_sample(struct thread *thread,
 	if (chain)
 		chain_nr = chain->nr;

-	if (evsel__has_branch_callstack(evsel)) {
+	if (chain && evsel__has_branch_callstack(evsel)) {
 		struct perf_env *env = evsel__env(evsel);

 		err = resolve_lbr_callchain_sample(thread, cursor, sample, parent,
-- 
2.27.0

             reply	other threads:[~2026-10-27 11:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-27 11:47 lv.yating [this message]
2026-10-27 15:21 ` Ian Rogers
2026-10-27 20:37   ` Arnaldo Carvalho de Melo
     [not found] <2026102719473296875zO7s1T904dguHCkN5vy@zte.com.cn>
2026-10-27 15:51 ` hu.shengming

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=202610271154.69RBsOlq045164@mse-fl2.zte.com.cn \
    --to=lv.yating@zte.com.cn \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=dai.hualiang@zte.com.cn \
    --cc=he.yilin@zte.com.cn \
    --cc=hu.shengming@zte.com.cn \
    --cc=irogers@google.com \
    --cc=james.clark@linaro.org \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=liu.qingtao2@zte.com.cn \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=shen.lin1@zte.com.cn \
    --cc=stable@vger.kernel.org \
    --cc=ye.zhihao1@zte.com.cn \
    --cc=zhang.cheng35@zte.com.cn \
    /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®