[PATCH] x86: fix initjmp storing base pointer at wrong address
Ahmad Fatoum
a.fatoum at barebox.org
Mon Mar 23 00:17:28 PDT 2026
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 at anthropic.com>
Signed-off-by: Ahmad Fatoum <a.fatoum at 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
More information about the barebox
mailing list