NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

PR/60653 CVS commit: [netbsd-10] src/sys/compat/linux32/arch/aarch64



The following reply was made to PR kern/60653; it has been noted by GNATS.

From: "Martin Husemann" <martin%netbsd.org@localhost>
To: gnats-bugs%gnats.NetBSD.org@localhost
Cc: 
Subject: PR/60653 CVS commit: [netbsd-10] src/sys/compat/linux32/arch/aarch64
Date: Sat, 24 Oct 2026 11:07:37 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Sat Oct 24 11:07:37 UTC 2026
 
 Modified Files:
 	src/sys/compat/linux32/arch/aarch64 [netbsd-10]: linux32_exec_machdep.c
 
 Log Message:
 Pull up the following requested by riastradh in ticket #1386:
 
 	sys/compat/linux32/arch/aarch64/linux32_exec_machdep.c 1.3 (patch)
 
 execve(2): Set p_stackbase in execve_runproc, not execve_loadvm.
 
 execve_loadvm must not have side effects on the running process for
 two reasons:
 
 1. If execve(2) fails, it has to be able to back out and return to
    the calling process.  For example, the shell will execute the
    first of a series of candidate paths that works when it searches
    $PATH, and if one fails, it has to be able to move on to try the
    next.
 
 2. The caller may be the _parent_ process -- this is the case when
    we're in posix_spawn.
 
 Instead, it must be set in execve_runproc, after we're committed to
 the exec and can't back out -- and we're definitely operating on the
 process that is executing a new image, not on its parent!
 
 p_stackbase and its assignment in exec_setup_stack, a subroutine of
 execve_loadvm, were introduced with the PaX ASLR changes back in 2007
 in order to pass the true stack base via AT_STACKBASE in the ELF
 auxv, and in order to have getcontext() return the true stack base,
 in the face of address space layout randomization.
 
 This change, however, broke the stack base returned by getcontext()
 in programs that have tried to exec other programs and failed in
 various ways.  And made the later introduction of posix_spawn break
 the stack base in the _parent_.
 
 To fix this, we set p_stackbase -- under p_lock, to avoid racing with
 sysctl_doeproc in another thread -- only in execve_runproc once we're
 committed to the exec, but before copyoutargs -> es_copyargs =
 elf_copyargs -> elf_populate_auxv needs to read it.  (That said,
 elf_populate_auxv(..., pack, ...) could just use pack->es_minsaddr
 directly anyway, and then we wouldn't have that ordering constraint.)
 
 PR kern/60653: posix_spawn(3) causes incorrect stack base information
 
 
 To generate a diff of this commit:
 cvs rdiff -u -r1.1 -r1.1.4.1 \
     src/sys/compat/linux32/arch/aarch64/linux32_exec_machdep.c
 
 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.
 



Home | Main Index | Thread Index | Old Index