| Summary: | [kernel] The kernel doesn't follow the calling convention in the SVR4/i386 ABI | ||
|---|---|---|---|
| Product: | Base System | Reporter: | Pedro F. Giffuni <pfgshield-freebsd> |
| Component: | amd64 | Assignee: | freebsd-amd64 (Nobody) <amd64> |
| Status: | Closed FIXED | ||
| Severity: | Affects Only Me | ||
| Priority: | Normal | ||
| Version: | Unspecified | ||
| Hardware: | Any | ||
| OS: | Any | ||
|
Description
Pedro F. Giffuni
2008-05-30 15:10:03 UTC
State Changed From-To: open->closed I don't think that this is na issue for the current codebase. If I am wrong, please follow up and/or re-open the PR. The code has certainly changed a lot ...=0A=0AReading the posting on the l= ink with a possible fix:=0A=0A"...=0ACan you try to add to kernel sources, = into file sys/amd64/amd64/machdep.c=0Afunction exec_setregs(td, entry, stac= k, ps_strings)=0Asomewhere at the end=0A=0A=09pcb->pcb_flags |=3D PCB_FULLC= TX;=0A... "=0A=0AWe don't have anything similar to this in exec_setregs(), = and from my understanding the issue could not be easily fixed without break= ing binary compatibility so I would think the issue is still there.=0A=0ATh= is PR was only for reference though as it doesn't cause trouble for us: I'm= OK with the PR being closed.=0A=0A=0A=0A On Sun, Dec 05, 2010 at 07:08:07AM -0800, pfgshield-freebsd@yahoo.com wrote: > The code has certainly changed a lot ... > > Reading the posting on the link with a possible fix: > > "... > Can you try to add to kernel sources, into file sys/amd64/amd64/machdep.c > function exec_setregs(td, entry, stack, ps_strings) > somewhere at the end > > pcb->pcb_flags |= PCB_FULLCTX; > ... " > > We don't have anything similar to this in exec_setregs(), and from my understanding the issue could not be easily fixed without breaking binary compatibility so I would think the issue is still there. > > This PR was only for reference though as it doesn't cause trouble for us: I'm OK with the PR being closed. > I looked at the PR before. Looking again now, I have the same conclusion, that is I do not understand what is the issue. On the first return into usermode after the successfull execve(2), kernel sets the following registers: - %rsp (properly aligned) - %rdi (1st parameter in usermode ABI; contains the pointer to startup frame, i.e. &argc) - all other GP registers are zeroed. ABI rev. 0.99 requires the following setup: - %rsp properly aligned and has the value &argc - %rdx points to a function to be registered with atexit(3), or NULL. We do satisfy the ABI requirement for %rdx content in the trivial way, by passing 0. The layout of the startup frame also seems conforming. Author: kib Date: Mon Dec 6 15:15:27 2010 New Revision: 216231 URL: http://svn.freebsd.org/changeset/base/216231 Log: 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 <Petr.Salinger seznam cz> (who convinced me that there is indeed several bugs) MFC after: 1 week Modified: head/sys/amd64/amd64/machdep.c Modified: head/sys/amd64/amd64/machdep.c ============================================================================== --- head/sys/amd64/amd64/machdep.c Mon Dec 6 12:18:02 2010 (r216230) +++ head/sys/amd64/amd64/machdep.c Mon Dec 6 15:15:27 2010 (r216231) @@ -876,6 +876,7 @@ exec_setregs(struct thread *td, struct i 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. _______________________________________________ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org" |