PERFORCE change 84048 for review

Robert Watson rwatson at FreeBSD.org
Wed Sep 21 11:21:37 GMT 2005


http://perforce.freebsd.org/chv.cgi?CH=84048

Change 84048 by rwatson at rwatson_zoo on 2005/09/21 11:20:54

	When canonicalizing a path, rather than asserting Giant,
	conditionally acquire it around VFS operations if needed.

Affected files ...

.. //depot/projects/trustedbsd/audit3/sys/security/audit/kern_bsm_klib.c#10 edit

Differences ...

==== //depot/projects/trustedbsd/audit3/sys/security/audit/kern_bsm_klib.c#10 (text+ko) ====

@@ -25,6 +25,7 @@
 #include <sys/filedesc.h>
 #include <sys/libkern.h>
 #include <sys/malloc.h>
+#include <sys/mount.h>
 #include <sys/proc.h>
 #include <sys/sem.h>
 #include <sys/syscall.h>
@@ -400,16 +401,16 @@
  * written to the audit log. So we will leave the filename starting
  * with '/' in the audit log in this case.
  */
-void canon_path(struct thread *td, char *path, char *cpath)
+void
+canon_path(struct thread *td, char *path, char *cpath)
 {
 	char *bufp;
 	char *retbuf, *freebuf;
 	int len;
 	struct vnode *vnp;
 	struct filedesc *fdp;
+	int vfslocked;
 
-	mtx_assert(&Giant, MA_OWNED);
-
 	fdp = td->td_proc->p_fd;
 	bufp = path;
 	FILEDESC_LOCK(fdp);
@@ -444,6 +445,7 @@
 		 * string bounding here seems a bit questionable and
 		 * will also require attention.
 		 */
+		vfslocked = VFS_LOCK_GIANT(vnp->v_mount);
 		vn_lock(vnp, LK_EXCLUSIVE | LK_RETRY, td);
 		if (vn_fullpath(td, vnp, &retbuf, &freebuf) == 0) {
 			/* Copy and free buffer allocated by vn_fullpath() */
@@ -454,6 +456,7 @@
 			cpath[0] = '\0';
 		}
 		vput(vnp);
+		VFS_UNLOCK_GIANT(vfslocked);
 		len = strlen(cpath);
 		strncpy(cpath + len-1, bufp, MAXPATHLEN - len);
 	} else {
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