Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 21 Jun 2009 19:21:01 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r194601 - in head/sys: fs/nullfs kern sys
Message-ID:  <200906211921.n5LJL103015999@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Sun Jun 21 19:21:01 2009
New Revision: 194601
URL: http://svn.freebsd.org/changeset/base/194601

Log:
  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

Modified:
  head/sys/fs/nullfs/null_vnops.c
  head/sys/kern/vfs_cache.c
  head/sys/kern/vfs_default.c
  head/sys/kern/vnode_if.src
  head/sys/sys/vnode.h

Modified: head/sys/fs/nullfs/null_vnops.c
==============================================================================
--- head/sys/fs/nullfs/null_vnops.c	Sun Jun 21 19:17:22 2009	(r194600)
+++ head/sys/fs/nullfs/null_vnops.c	Sun Jun 21 19:21:01 2009	(r194601)
@@ -747,6 +747,7 @@ null_vptocnp(struct vop_vptocnp_args *ap
 	struct vnode *vp = ap->a_vp;
 	struct vnode **dvp = ap->a_vpp;
 	struct vnode *lvp, *ldvp;
+	struct ucred *cred = ap->a_cred;
 	int error, locked;
 
 	if (vp->v_type == VDIR)
@@ -757,7 +758,7 @@ null_vptocnp(struct vop_vptocnp_args *ap
 	vhold(lvp);
 	VOP_UNLOCK(vp, 0); /* vp is held by vn_vptocnp_locked that called us */
 	ldvp = lvp;
-	error = vn_vptocnp(&ldvp, ap->a_buf, ap->a_buflen);
+	error = vn_vptocnp(&ldvp, cred, ap->a_buf, ap->a_buflen);
 	vdrop(lvp);
 	if (error != 0) {
 		vn_lock(vp, locked | LK_RETRY);

Modified: head/sys/kern/vfs_cache.c
==============================================================================
--- head/sys/kern/vfs_cache.c	Sun Jun 21 19:17:22 2009	(r194600)
+++ head/sys/kern/vfs_cache.c	Sun Jun 21 19:21:01 2009	(r194601)
@@ -206,7 +206,8 @@ SYSCTL_OPAQUE(_vfs_cache, OID_AUTO, nchs
 
 
 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, st
 }
 
 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,
 }
 
 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, cha
 	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 v
 	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 v
 			    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) {

Modified: head/sys/kern/vfs_default.c
==============================================================================
--- head/sys/kern/vfs_default.c	Sun Jun 21 19:17:22 2009	(r194600)
+++ head/sys/kern/vfs_default.c	Sun Jun 21 19:21:01 2009	(r194601)
@@ -693,6 +693,7 @@ vop_stdvptocnp(struct vop_vptocnp_args *
 {
 	struct vnode *vp = ap->a_vp;
 	struct vnode **dvp = ap->a_vpp;
+	struct ucred *cred = ap->a_cred;
 	char *buf = ap->a_buf;
 	int *buflen = ap->a_buflen;
 	char *dirbuf, *cpos;
@@ -713,7 +714,7 @@ vop_stdvptocnp(struct vop_vptocnp_args *
 	if (vp->v_type != VDIR)
 		return (ENOENT);
 
-	error = VOP_GETATTR(vp, &va, td->td_ucred);
+	error = VOP_GETATTR(vp, &va, cred);
 	if (error)
 		return (error);
 
@@ -723,7 +724,7 @@ vop_stdvptocnp(struct vop_vptocnp_args *
 	NDINIT_ATVP(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_SYSSPACE,
 	    "..", vp, td);
 	flags = FREAD;
-	error = vn_open_cred(&nd, &flags, 0, VN_OPEN_NOAUDIT, NULL, NULL);
+	error = vn_open_cred(&nd, &flags, 0, VN_OPEN_NOAUDIT, cred, NULL);
 	if (error) {
 		vn_lock(vp, locked | LK_RETRY);
 		return (error);
@@ -738,7 +739,7 @@ vop_stdvptocnp(struct vop_vptocnp_args *
 		*dvp = (*dvp)->v_mount->mnt_vnodecovered;
 		VREF(mvp);
 		VOP_UNLOCK(mvp, 0);
-		vn_close(mvp, FREAD, td->td_ucred, td);
+		vn_close(mvp, FREAD, cred, td);
 		VREF(*dvp);
 		vn_lock(*dvp, LK_EXCLUSIVE | LK_RETRY);
 		covered = 1;
@@ -803,7 +804,7 @@ out:
 		vrele(mvp);
 	} else {
 		VOP_UNLOCK(mvp, 0);
-		vn_close(mvp, FREAD, td->td_ucred, td);
+		vn_close(mvp, FREAD, cred, td);
 	}
 	vn_lock(vp, locked | LK_RETRY);
 	return (error);

Modified: head/sys/kern/vnode_if.src
==============================================================================
--- head/sys/kern/vnode_if.src	Sun Jun 21 19:17:22 2009	(r194600)
+++ head/sys/kern/vnode_if.src	Sun Jun 21 19:21:01 2009	(r194601)
@@ -607,6 +607,7 @@ vop_vptofh {
 vop_vptocnp {
 	IN struct vnode *vp;
 	OUT struct vnode **vpp;
+	IN struct ucred *cred;
 	INOUT char *buf;
 	INOUT int *buflen;
 };

Modified: head/sys/sys/vnode.h
==============================================================================
--- head/sys/sys/vnode.h	Sun Jun 21 19:17:22 2009	(r194600)
+++ head/sys/sys/vnode.h	Sun Jun 21 19:21:01 2009	(r194601)
@@ -601,7 +601,8 @@ int	insmntque1(struct vnode *vp, struct 
 int	insmntque(struct vnode *vp, struct mount *mp);
 u_quad_t init_va_filerev(void);
 int	speedup_syncer(void);
-int	vn_vptocnp(struct vnode **vp, char *buf, u_int *buflen);
+int	vn_vptocnp(struct vnode **vp, struct ucred *cred, char *buf,
+	    u_int *buflen);
 #define textvp_fullpath(p, rb, rfb) \
 	vn_fullpath(FIRST_THREAD_IN_PROC(p), (p)->p_textvp, rb, rfb)
 int	vn_fullpath(struct thread *td, struct vnode *vn,



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