diff options
author | jhb <jhb@FreeBSD.org> | 2001-11-12 18:56:49 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2001-11-12 18:56:49 +0000 |
commit | c7338726d95c9981686875afc8726078ab7ff821 (patch) | |
tree | 6784b34e0d65d632d9d07c0889679e638d222d5f /sys/kern/kern_proc.c | |
parent | 0c3e87867faeb5fedd10ede031b2c5573c4154fa (diff) | |
download | FreeBSD-src-c7338726d95c9981686875afc8726078ab7ff821.zip FreeBSD-src-c7338726d95c9981686875afc8726078ab7ff821.tar.gz |
Clean up breakage in inferior() I introduced in 1.92 of kern_proc.c:
- Restore inferior() to being iterative rather than recursive.
- Assert that the proctree_lock is held in inferior() and change the one
caller to get a shared lock of it. This also ensures that we hold the
lock after performing the check so the check can't be made invalid out
from under us after the check but before we act on it.
Requested by: bde
Diffstat (limited to 'sys/kern/kern_proc.c')
-rw-r--r-- | sys/kern/kern_proc.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c index 6647f73..4b1f492 100644 --- a/sys/kern/kern_proc.c +++ b/sys/kern/kern_proc.c @@ -183,16 +183,14 @@ int inferior(p) register struct proc *p; { - int rval; + int rval = 1; - PROC_LOCK_ASSERT(p, MA_OWNED); - if (p == curproc) - return (1); - if (p->p_pid == 0) - return (0); - PROC_LOCK(p->p_pptr); - rval = inferior(p->p_pptr); - PROC_UNLOCK(p->p_pptr); + sx_assert(&proctree_lock, SX_LOCKED); + for (; p != curproc; p = p->p_pptr) + if (p->p_pid == 0) { + rval = 0; + break; + } return (rval); } |