kernel - Fix exit races which can lead to a corrupt p_children list
authorMatthew Dillon <dillon@apollo.backplane.com>
Thu, 16 Aug 2012 01:11:11 +0000 (18:11 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Tue, 21 Aug 2012 03:58:50 +0000 (20:58 -0700)
commit1a3fa08b54907be4aeaaec7a391893d5665c49c8
tree468314b1f424e673bb87622a206549169b6bc7a5
parent2fe8ae78141643d333e714f27ad9ce515ce5c9bc
kernel - Fix exit races which can lead to a corrupt p_children list

* There are a few races when getting multiple tokens where a threaded
  process is wait*()ing for exiting children from multiple threads
  at once.

  Fix the problem by serializing the operation on a per-child basis,
  and by using PHOLD/PRELE prior to acquiring the child's p_token.
  Then re-check the conditions before accepting the child.

* There is a small chance this will also reduce or fix VM on-exit races
  in i386, as this bug could result in an already-destroyed process
  being pulled off by the racing wait*().  Maybe 25% chance.
sys/kern/kern_exit.c
sys/kern/kern_proc.c
sys/sys/proc.h