[PATCH 1/2] arm64: stacktrace: Check kretprobe_find_ret_addr() return value

Mark Rutland mark.rutland at arm.com
Wed May 21 04:09:59 PDT 2025


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 at arm.com>
Cc: Andrea della Porta <andrea.porta at suse.com>
Cc: Breno Leitao <leitao at debian.org>
Cc: Catalin Marinas <catalin.marinas at arm.com>
Cc: Josh Poimboeuf <jpoimboe at kernel.org>
Cc: Miroslav Benes <mbenes at suse.cz>
Cc: Petr Mladek <pmladek at suse.com>
Cc: Song Liu <song at kernel.org>
Cc: Will Deacon <will at 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




More information about the linux-arm-kernel mailing list