DragonFly commits List (threaded) for 2011-11
git: kernel - Fix race between procfs / proc sysctls and exec, refactor PHOLD/etc
Author: Matthew Dillon <email@example.com>
Date: Wed Nov 30 20:29:15 2011 -0800
kernel - Fix race between procfs / proc sysctls and exec, refactor PHOLD/etc
* During a [v]fork/exec sequence the exec will replace the VM space of the
target process. A concurrent 'ps' operation could access the target
process's vmspace as it was being ripped out, resulting in memory
* The P_INEXEC test in procfs was insufficient, the exec code itself must
also wait for procfs's PHOLD() on the process to go away before it can
proceed. This should properly interlock the entire operation.
* Can occur with procfs or non-procfs ps's (via proc sysctls).
* Possibly related to the seg-fault issue we have where the user stack gets
* Also revamp PHOLD()/PRELE() and add PSTALL(), changing all manual while()
loops waiting on p->p_lock to use PSTALL().
These functions now integrate a wakeup request flag into p->p_lock
using atomic ops and no longer tsleep() for 1 tick (or hz ticks, or
whatever). Wakeups are issued proactively.
Summary of changes:
sys/kern/kern_exec.c | 12 ++++++
sys/kern/kern_exit.c | 27 +++++++-----
sys/kern/kern_proc.c | 93 ++++++++++++++++++++++++++++++++++++++++---
sys/sys/proc.h | 9 +++-
sys/vfs/procfs/procfs_mem.c | 3 +-
5 files changed, 124 insertions(+), 20 deletions(-)
DragonFly BSD source repository