changeset 11974:5dc5c5cda3f3

6932898 panic: assertion failed: vp->v_rdcnt > 0, file: ../../common/fs/vnode.c, line: 3175 6934241 running a setuid script with an invalid interpreter panics system
author Donghai Qiao <Donghai.Qiao@Sun.COM>
date Mon, 22 Mar 2010 17:10:24 -0400
parents 480f5412d630
children 831d27fe2446
files usr/src/uts/common/os/exec.c
diffstat 1 files changed, 12 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/uts/common/os/exec.c	Mon Mar 22 13:57:47 2010 -0700
+++ b/usr/src/uts/common/os/exec.c	Mon Mar 22 17:10:24 2010 -0400
@@ -703,11 +703,18 @@
 	    setidfl, exec_file, cred, brand_action);
 	rw_exit(eswp->exec_lock);
 	if (error != 0) {
-		if (newcred != NULL)
-			crfree(newcred);
 		if (execvp)
 			VN_RELE(execvp);
-		goto bad;
+		/*
+		 * If this process's p_exec has been set to the vp of
+		 * the executable by exec_func, we will return without
+		 * calling VOP_CLOSE because proc_exit will close it
+		 * on exit.
+		 */
+		if (pp->p_exec == vp)
+			goto bad_noclose;
+		else
+			goto bad;
 	}
 
 	if (level == 0) {
@@ -797,6 +804,8 @@
 	(void) VOP_CLOSE(vp, FREAD, 1, (offset_t)0, cred, NULL);
 
 bad_noclose:
+	if (newcred != NULL)
+		crfree(newcred);
 	if (error == 0)
 		error = ENOEXEC;