linux-toolchains.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
To: linux-arm-kernel@lists.infradead.org
Cc: andrea.porta@suse.com, catalin.marinas@arm.com,
	jpoimboe@kernel.org, leitao@debian.org,
	linux-toolchains@vger.kernel.org, live-patching@vger.kernel.org,
	mark.rutland@arm.com, mbenes@suse.cz, pmladek@suse.com,
	song@kernel.org, will@kernel.org
Subject: [PATCH 1/2] arm64: stacktrace: Check kretprobe_find_ret_addr() return value
Date: Wed, 21 May 2025 12:09:59 +0100	[thread overview]
Message-ID: <20250521111000.2237470-2-mark.rutland@arm.com> (raw)
In-Reply-To: <20250521111000.2237470-1-mark.rutland@arm.com>

If kretprobe_find_ret_addr() fails to find the original return address,
it returns 0. Check for this case so that a reliable stacktrace won't
silently ignore it.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Andrea della Porta <andrea.porta@suse.com>
Cc: Breno Leitao <leitao@debian.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Josh Poimboeuf <jpoimboe@kernel.org>
Cc: Miroslav Benes <mbenes@suse.cz>
Cc: Petr Mladek <pmladek@suse.com>
Cc: Song Liu <song@kernel.org>
Cc: Will Deacon <will@kernel.org>
---
 arch/arm64/kernel/stacktrace.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm64/kernel/stacktrace.c b/arch/arm64/kernel/stacktrace.c
index 1d9d51d7627fd..f6494c0942144 100644
--- a/arch/arm64/kernel/stacktrace.c
+++ b/arch/arm64/kernel/stacktrace.c
@@ -152,6 +152,8 @@ kunwind_recover_return_address(struct kunwind_state *state)
 		orig_pc = kretprobe_find_ret_addr(state->task,
 						  (void *)state->common.fp,
 						  &state->kr_cur);
+		if (!orig_pc)
+			return -EINVAL;
 		state->common.pc = orig_pc;
 		state->flags.kretprobe = 1;
 	}
-- 
2.30.2


  reply	other threads:[~2025-05-21 11:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-21 11:09 [PATCH 0/2] arm64: stacktrace: Enable reliable stacktrace Mark Rutland
2025-05-21 11:09 ` Mark Rutland [this message]
2025-05-21 16:35   ` [PATCH 1/2] arm64: stacktrace: Check kretprobe_find_ret_addr() return value Song Liu
2025-05-21 11:10 ` [PATCH 2/2] arm64: stacktrace: Implement arch_stack_walk_reliable() Mark Rutland
2025-06-20 12:35 ` [PATCH 0/2] arm64: stacktrace: Enable reliable stacktrace Catalin Marinas
2025-06-20 20:45   ` Song Liu

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=20250521111000.2237470-2-mark.rutland@arm.com \
    --to=mark.rutland@arm.com \
    --cc=andrea.porta@suse.com \
    --cc=catalin.marinas@arm.com \
    --cc=jpoimboe@kernel.org \
    --cc=leitao@debian.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-toolchains@vger.kernel.org \
    --cc=live-patching@vger.kernel.org \
    --cc=mbenes@suse.cz \
    --cc=pmladek@suse.com \
    --cc=song@kernel.org \
    --cc=will@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).