mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@barebox.org>
To: barebox@lists.infradead.org
Cc: "Claude Opus 4.6" <noreply@anthropic.com>,
	Ahmad Fatoum <a.fatoum@barebox.org>
Subject: [PATCH] x86: fix initjmp storing base pointer at wrong address
Date: Mon, 23 Mar 2026 08:17:28 +0100	[thread overview]
Message-ID: <20260323071738.4005127-1-a.fatoum@barebox.org> (raw)

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




                 reply	other threads:[~2026-03-23  7:18 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20260323071738.4005127-1-a.fatoum@barebox.org \
    --to=a.fatoum@barebox.org \
    --cc=barebox@lists.infradead.org \
    --cc=noreply@anthropic.com \
    /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