Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 4 Jul 2005 14:52:31 GMT
From:      "Christian S.J. Peron" <csjp@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 79559 for review
Message-ID:  <200507041452.j64EqVNt087052@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=79559

Change 79559 by csjp@csjp_xor on 2005/07/04 14:51:31

	Make VFS operations performed by mac_chkexec MPsafe through the aquisition
	of giant. Giant is now aquired while:
	
	1) Calculation and storage of current file checksum
	2) Calculation and lookup of checksums associated with dependencies.

Affected files ...

.. //depot/projects/trustedbsd/mac/sys/security/mac_chkexec/mac_chkexec.c#12 edit

Differences ...

==== //depot/projects/trustedbsd/mac/sys/security/mac_chkexec/mac_chkexec.c#12 (text+ko) ====

@@ -531,15 +531,18 @@
 			if (++ap >= &paths[10])
 				break;
 	for (i = 0; i < npaths; i++) {
+		mtx_lock(&Giant);
 		NDINIT(&nd, LOOKUP, LOCKLEAF | FOLLOW,
 		    UIO_SYSSPACE, paths[i], curthread);
 		if ((error = namei(&nd)) != 0) {
 			free(depends, M_CHKEXEC);
+			mtx_unlock(&Giant);
 			return (error);
 		}
 		error = mac_chkexec_check(nd.ni_vp, cred);
 		NDFREE(&nd, NDF_ONLY_PNBUF);
 		vput(nd.ni_vp);
+		mtx_unlock(&Giant);
 		if (error) {
 			free(depends, M_CHKEXEC);
 			return (error);
@@ -841,13 +844,17 @@
 		return (EPERM);
 	}
 	/* XXX MPSAFE VFS */
+	mtx_lock(&Giant);
 	NDINIT(&nd, LOOKUP, LOCKLEAF | FOLLOW, UIO_USERSPACE, arg, td);
-	if ((error = namei(&nd)) != 0)
+	if ((error = namei(&nd)) != 0) {
+		mtx_unlock(&Giant);
 		return (error);
+	}
 	error = ha->crypto_hash(nd.ni_vp, td->td_ucred, digest);
 	if (error) {
 		NDFREE(&nd, NDF_ONLY_PNBUF); 
 		vput(nd.ni_vp);
+		mtx_unlock(&Giant);
 		return (error);
 	}
 	bzero(&vcsum, sizeof(vcsum));
@@ -856,6 +863,7 @@
 	error = mac_chkexec_set_vcsum(nd.ni_vp, &vcsum);
 	NDFREE(&nd, NDF_ONLY_PNBUF);
 	vput(nd.ni_vp);
+	mtx_unlock(&Giant);
 	return (error);
 }
 



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