Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 10 Apr 2011 17:07:03 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r220526 - head/sys/kern
Message-ID:  <201104101707.p3AH736T054347@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Sun Apr 10 17:07:02 2011
New Revision: 220526
URL: http://svn.freebsd.org/changeset/base/220526

Log:
  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>

Modified:
  head/sys/kern/kern_exit.c

Modified: head/sys/kern/kern_exit.c
==============================================================================
--- head/sys/kern/kern_exit.c	Sun Apr 10 15:48:16 2011	(r220525)
+++ head/sys/kern/kern_exit.c	Sun Apr 10 17:07:02 2011	(r220526)
@@ -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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201104101707.p3AH736T054347>