* [PATCH] x86: fix initjmp storing base pointer at wrong address
@ 2026-03-23 7:17 Ahmad Fatoum
0 siblings, 0 replies; only message in thread
From: Ahmad Fatoum @ 2026-03-23 7:17 UTC (permalink / raw)
To: barebox; +Cc: Claude Opus 4.6, Ahmad Fatoum
initjmp was writing zero to 8(%edx), which is func + 8 (corrupting
memory at the function pointer address), instead of 8(%eax), which is
the __ebp (base pointer) slot in the jmp_buf. When longjmp later
restored the buffer, it would load uninitialized data into %ebp.
With regparm(3), the arguments are passed as:
%eax = jmp_buf, %edx = func, %ecx = stack_top
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
arch/x86/lib/setjmp_32.S | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/lib/setjmp_32.S b/arch/x86/lib/setjmp_32.S
index cf340d35d8fd..ff080179ef9d 100644
--- a/arch/x86/lib/setjmp_32.S
+++ b/arch/x86/lib/setjmp_32.S
@@ -56,7 +56,7 @@ ENDPROC(longjmp)
ENTRY(initjmp)
movl %edx, 20(%eax) /* Return address */
- movl $0, 8(%edx) /* Base pointer */
+ movl $0, 8(%eax) /* Base pointer */
sub $ASM_SZPTR, %ecx /* ESP - 4 has to be 16-byte aligned on entry */
movl %ecx, 4(%eax) /* Stack top */
xorl %eax, %eax /* Return value */
--
2.47.3
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-03-23 7:18 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-23 7:17 [PATCH] x86: fix initjmp storing base pointer at wrong address Ahmad Fatoum
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox