[PATCH v2025.09.y 54/58] powerpc: fix initjmp storing function pointer at wrong offset
Ahmad Fatoum
a.fatoum at pengutronix.de
Fri Mar 13 06:25:38 PDT 2026
From: Ahmad Fatoum <a.fatoum at barebox.org>
initjmp was storing the function pointer at offset 88, which is the CR
(condition register) slot in the jmp_buf, instead of offset 84, which is
the LR (link register) slot. When longjmp later restored the buffer, it
would load uninitialized data into LR and jump to it, causing a crash.
This was caught by the setjmp selftest, which triggered a reboot loop on
qemu-ppce500.
(cherry picked from commit bb1ddbf129b6f0081f7c44b726d96f18eeaec6aa)
Co-Authored-By: Claude Opus 4.6 <noreply at anthropic.com>
Signed-off-by: Ahmad Fatoum <a.fatoum at barebox.org>
Link: https://lore.barebox.org/20260302134843.195007-3-a.fatoum@barebox.org
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
arch/powerpc/lib/setjmp.S | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/lib/setjmp.S b/arch/powerpc/lib/setjmp.S
index 021a57eebc3c..7f4d041ce213 100644
--- a/arch/powerpc/lib/setjmp.S
+++ b/arch/powerpc/lib/setjmp.S
@@ -79,8 +79,8 @@ END(longjmp)
ENTRY(initjmp)
addi r3,r3,7 # align to 8 byte boundary
rlwinm r3,r3,0,0,28
- stw r5,0(r3) # offset 0
- stwu r4,88(r3) # offset 88
+ stw r5,0(r3) # offset 0 - stack pointer
+ stw r4,84(r3) # offset 84 - link register
li r3,0
blr
END(initjmp)
--
2.47.3
More information about the barebox
mailing list