Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 9 Feb 2012 10:30:45 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r231268 - stable/9/sys/kern
Message-ID:  <201202091030.q19AUjVW094185@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Thu Feb  9 10:30:45 2012
New Revision: 231268
URL: http://svn.freebsd.org/changeset/base/231268

Log:
  MFC r230341:
  Use shared lock for the executable vnode in the exec path after the
  VV_TEXT changes are handled. Assert that vnode is exclusively locked at
  the places that modify VV_TEXT.

Modified:
  stable/9/sys/kern/kern_exec.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/kern/kern_exec.c
==============================================================================
--- stable/9/sys/kern/kern_exec.c	Thu Feb  9 10:22:08 2012	(r231267)
+++ stable/9/sys/kern/kern_exec.c	Thu Feb  9 10:30:45 2012	(r231268)
@@ -471,6 +471,7 @@ interpret:
 	 * actually an executable image.
 	 */
 	textset = imgp->vp->v_vflag & VV_TEXT;
+	ASSERT_VOP_ELOCKED(imgp->vp, "vv_text");
 	imgp->vp->v_vflag |= VV_TEXT;
 
 	error = exec_map_first_page(imgp);
@@ -502,8 +503,10 @@ interpret:
 
 	if (error) {
 		if (error == -1) {
-			if (textset == 0)
+			if (textset == 0) {
+				ASSERT_VOP_ELOCKED(imgp->vp, "vv_text");
 				imgp->vp->v_vflag &= ~VV_TEXT;
+			}
 			error = ENOEXEC;
 		}
 		goto exec_fail_dealloc;
@@ -596,7 +599,7 @@ interpret:
 
 	/* close files on exec */
 	fdcloseexec(td);
-	vn_lock(imgp->vp, LK_EXCLUSIVE | LK_RETRY);
+	vn_lock(imgp->vp, LK_SHARED | LK_RETRY);
 
 	/* Get a reference to the vnode prior to locking the proc */
 	VREF(binvp);
@@ -701,7 +704,7 @@ interpret:
 		VOP_UNLOCK(imgp->vp, 0);
 		setugidsafety(td);
 		error = fdcheckstd(td);
-		vn_lock(imgp->vp, LK_EXCLUSIVE | LK_RETRY);
+		vn_lock(imgp->vp, LK_SHARED | LK_RETRY);
 		if (error != 0)
 			goto done1;
 		PROC_LOCK(p);
@@ -805,7 +808,7 @@ interpret:
 		pe.pm_entryaddr = imgp->entry_addr;
 
 		PMC_CALL_HOOK_X(td, PMC_FN_PROCESS_EXEC, (void *) &pe);
-		vn_lock(imgp->vp, LK_EXCLUSIVE | LK_RETRY);
+		vn_lock(imgp->vp, LK_SHARED | LK_RETRY);
 	} else
 		PROC_UNLOCK(p);
 #else  /* !HWPMC_HOOKS */
@@ -857,7 +860,7 @@ done1:
 	if (tracecred != NULL)
 		crfree(tracecred);
 #endif
-	vn_lock(imgp->vp, LK_EXCLUSIVE | LK_RETRY);
+	vn_lock(imgp->vp, LK_SHARED | LK_RETRY);
 	pargs_drop(oldargs);
 	pargs_drop(newargs);
 	if (oldsigacts != NULL)



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