From 2fc79768f33d575d200ae1482dc23207f9d93703 Mon Sep 17 00:00:00 2001 From: kib Date: Sun, 21 Jun 2009 19:21:01 +0000 Subject: Add explicit struct ucred * argument for VOP_VPTOCNP, to be used by vn_open_cred in default implementation. Valid struct ucred is needed for audit and MAC, and curthread credentials may be wrong. This further requires modifying the interface of vn_fullpath(9), but it is out of scope of this change. Reviewed by: rwatson --- sys/kern/vfs_cache.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'sys/kern/vfs_cache.c') diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index 0bd7975..f21f4af 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -206,7 +206,8 @@ SYSCTL_OPAQUE(_vfs_cache, OID_AUTO, nchstats, CTLFLAG_RD | CTLFLAG_MPSAFE, static void cache_zap(struct namecache *ncp); -static int vn_vptocnp_locked(struct vnode **vp, char *buf, u_int *buflen); +static int vn_vptocnp_locked(struct vnode **vp, struct ucred *cred, char *buf, + u_int *buflen); static int vn_fullpath1(struct thread *td, struct vnode *vp, struct vnode *rdir, char *buf, char **retbuf, u_int buflen); @@ -1037,12 +1038,12 @@ vn_fullpath_global(struct thread *td, struct vnode *vn, } int -vn_vptocnp(struct vnode **vp, char *buf, u_int *buflen) +vn_vptocnp(struct vnode **vp, struct ucred *cred, char *buf, u_int *buflen) { int error; CACHE_RLOCK(); - error = vn_vptocnp_locked(vp, buf, buflen); + error = vn_vptocnp_locked(vp, cred, buf, buflen); if (error == 0) { /* * vn_vptocnp_locked() dropped hold acquired by @@ -1057,7 +1058,8 @@ vn_vptocnp(struct vnode **vp, char *buf, u_int *buflen) } static int -vn_vptocnp_locked(struct vnode **vp, char *buf, u_int *buflen) +vn_vptocnp_locked(struct vnode **vp, struct ucred *cred, char *buf, + u_int *buflen) { struct vnode *dvp; struct namecache *ncp; @@ -1089,7 +1091,7 @@ vn_vptocnp_locked(struct vnode **vp, char *buf, u_int *buflen) CACHE_RUNLOCK(); vfslocked = VFS_LOCK_GIANT((*vp)->v_mount); vn_lock(*vp, LK_SHARED | LK_RETRY); - error = VOP_VPTOCNP(*vp, &dvp, buf, buflen); + error = VOP_VPTOCNP(*vp, &dvp, cred, buf, buflen); VOP_UNLOCK(*vp, 0); vdrop(*vp); VFS_UNLOCK_GIANT(vfslocked); @@ -1137,7 +1139,7 @@ vn_fullpath1(struct thread *td, struct vnode *vp, struct vnode *rdir, numfullpathcalls++; CACHE_RLOCK(); if (vp->v_type != VDIR) { - error = vn_vptocnp_locked(&vp, buf, &buflen); + error = vn_vptocnp_locked(&vp, td->td_ucred, buf, &buflen); if (error) return (error); if (buflen == 0) { @@ -1167,7 +1169,7 @@ vn_fullpath1(struct thread *td, struct vnode *vp, struct vnode *rdir, error, vp, NULL, 0, 0); break; } - error = vn_vptocnp_locked(&vp, buf, &buflen); + error = vn_vptocnp_locked(&vp, td->td_ucred, buf, &buflen); if (error) break; if (buflen == 0) { -- cgit v1.1