From 3e0ddb6781181e3d70887e6aa0a56bd32814f690 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Mon, 6 Dec 2010 15:15:27 +0000 Subject: [PATCH] Do not leak %rdx value in the previous image to the new image after execve(2). Note that ia32 binaries already handle this properly, since ia32_setregs() resets td_retval[1], but not exec_setregs(). We still do not conform to the amd64 ABI specification, since %rsp on the image startup is not aligned to 16 bytes. PR: amd64/124134 Discussed with: Petr Salinger (who convinced me that there is indeed several bugs) MFC after: 1 week --- sys/amd64/amd64/machdep.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c index 584473df5117..1cc9a4aa079c 100644 --- a/sys/amd64/amd64/machdep.c +++ b/sys/amd64/amd64/machdep.c @@ -876,6 +876,7 @@ exec_setregs(struct thread *td, struct image_params *imgp, u_long stack) regs->tf_fs = _ufssel; regs->tf_gs = _ugssel; regs->tf_flags = TF_HASSEGS; + td->td_retval[1] = 0; /* * Reset the hardware debug registers if they were in use.