DragonFly BSD
DragonFly commits List (threaded) for 2011-11
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

git: kernel - Fix race between procfs / proc sysctls and exec, refactor PHOLD/etc


From: Matthew Dillon <dillon@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 30 Nov 2011 20:38:20 -0800 (PST)

commit 82354ad856881fcddea37e6fbb8dae0a683f2ffb
Author: Matthew Dillon <dillon@apollo.backplane.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
      corruption.
    
    * 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
      corrupted.
    
    * 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(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/82354ad856881fcddea37e6fbb8dae0a683f2ffb


-- 
DragonFly BSD source repository



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