summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_exit.c
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2011-04-10 17:07:02 +0000
committerkib <kib@FreeBSD.org>2011-04-10 17:07:02 +0000
commit1b5526fe98e5e1efd20f4de381e17f750c7da264 (patch)
treef4411fe8fb79a757968ba169a80039b9772c4cb3 /sys/kern/kern_exit.c
parentcafda9c73f3b757beeea54be85d88029974949cd (diff)
downloadFreeBSD-src-1b5526fe98e5e1efd20f4de381e17f750c7da264.zip
FreeBSD-src-1b5526fe98e5e1efd20f4de381e17f750c7da264.tar.gz
Some callers of proc_reparent() already have the parent process locked.
Detect the situation and avoid process lock recursion. Reported by: Fabian Keil <freebsd-listen fabiankeil de>
Diffstat (limited to 'sys/kern/kern_exit.c')
-rw-r--r--sys/kern/kern_exit.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c
index 5fec31b..2d35ed5 100644
--- a/sys/kern/kern_exit.c
+++ b/sys/kern/kern_exit.c
@@ -903,15 +903,19 @@ loop:
void
proc_reparent(struct proc *child, struct proc *parent)
{
+ int locked;
sx_assert(&proctree_lock, SX_XLOCKED);
PROC_LOCK_ASSERT(child, MA_OWNED);
if (child->p_pptr == parent)
return;
- PROC_LOCK(parent);
+ locked = PROC_LOCKED(parent);
+ if (!locked)
+ PROC_LOCK(parent);
racct_add_force(parent, RACCT_NPROC, 1);
- PROC_UNLOCK(parent);
+ if (!locked)
+ PROC_UNLOCK(parent);
PROC_LOCK(child->p_pptr);
racct_sub(child->p_pptr, RACCT_NPROC, 1);
sigqueue_take(child->p_ksi);
OpenPOWER on IntegriCloud