Date: Wed, 21 Sep 2005 11:21:37 GMT From: Robert Watson <rwatson@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 84048 for review Message-ID: <200509211121.j8LBLbYc041876@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=84048 Change 84048 by rwatson@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 {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200509211121.j8LBLbYc041876>