PERFORCE change 83723 for review
Christian S.J. Peron
csjp at FreeBSD.org
Fri Sep 16 01:35:11 GMT 2005
http://perforce.freebsd.org/chv.cgi?CH=83723
Change 83723 by csjp at csjp_xor on 2005/09/16 01:34:15
Conditionally pickup giant if the filesystem is not marked as being
MPsafe. This incorporates the new world order of VFS locking.
Affected files ...
.. //depot/projects/trustedbsd/mac/sys/security/mac_chkexec/mac_chkexec.c#15 edit
Differences ...
==== //depot/projects/trustedbsd/mac/sys/security/mac_chkexec/mac_chkexec.c#15 (text+ko) ====
@@ -507,7 +507,7 @@
{
struct nameidata nd;
char *depends, *ap;
- int alen, error;
+ int vfslocked, alen, error;
size_t ealen;
ASSERT_VOP_LOCKED(vp, "no vlock held");
@@ -531,18 +531,17 @@
for (; (ap = strsep(&depends, ":")) != NULL && error == 0;) {
if (strlen(ap) == 0)
continue;
- mtx_lock(&Giant);
- NDINIT(&nd, LOOKUP, LOCKLEAF | FOLLOW, UIO_SYSSPACE,
+ NDINIT(&nd, LOOKUP, MPSAFE | LOCKLEAF | FOLLOW, UIO_SYSSPACE,
ap, curthread);
if ((error = namei(&nd)) != 0) {
free(depends, M_CHKEXEC);
- mtx_unlock(&Giant);
return (error);
}
+ vfslocked = NDHASGIANT(&nd);
error = mac_chkexec_check(nd.ni_vp, cred);
NDFREE(&nd, NDF_ONLY_PNBUF);
vput(nd.ni_vp);
- mtx_unlock(&Giant);
+ VFS_UNLOCK_GIANT(vfslocked);
}
free(depends, M_CHKEXEC);
return (error);
@@ -813,7 +812,7 @@
{
u_char digest[MAXCSUMSIZE];
struct nameidata nd;
- int error;
+ int vfslocked, error;
struct hash_algo *ha;
struct mac_vcsum vcsum;
@@ -839,18 +838,16 @@
CTR0(KTR_MAC, "mac_chkexec_check: invalid checksum algorithm");
return (EPERM);
}
- /* XXX MPSAFE VFS */
- mtx_lock(&Giant);
- NDINIT(&nd, LOOKUP, LOCKLEAF | FOLLOW, UIO_USERSPACE, arg, td);
+ NDINIT(&nd, LOOKUP, MPSAFE | LOCKLEAF | FOLLOW, UIO_USERSPACE, arg, td);
if ((error = namei(&nd)) != 0) {
- mtx_unlock(&Giant);
return (error);
}
+ vfslocked = NDHASGIANT(&nd);
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);
+ VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
bzero(&vcsum, sizeof(vcsum));
@@ -859,7 +856,7 @@
error = mac_chkexec_set_vcsum(nd.ni_vp, &vcsum);
NDFREE(&nd, NDF_ONLY_PNBUF);
vput(nd.ni_vp);
- mtx_unlock(&Giant);
+ VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
To Unsubscribe: send mail to majordomo at trustedbsd.org
with "unsubscribe trustedbsd-cvs" in the body of the message
More information about the trustedbsd-cvs
mailing list