Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 5 Feb 2020 21:30:31 +0000 (UTC)
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r357605 - in stable: 11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs 11/sys/fs/pseudofs 12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs 12/sys/fs/pseudofs
Message-ID:  <202002052130.015LUVAE032739@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kevans
Date: Wed Feb  5 21:30:31 2020
New Revision: 357605
URL: https://svnweb.freebsd.org/changeset/base/357605

Log:
  MFC r357410-r357411: Avoid duplicating VEXEC checks in VOP_CACHEDLOOKUP
  
  r357410: pseudofs: don't do VEXEC check in VOP_CACHEDLOOKUP
  
  VOP_CACHEDLOOKUP should assume that the appropriate VEXEC check has been
  done in the caller (vfs_cache_lookup), so it does not belong here.
  
  r357411: zfs: light refactor to indicate cachedlookup in zfs_lookup
  
  If we come from VOP_CACHEDLOOKUP, we must skip the VEXEC check as it will
  have been done in the caller (vfs_cache_lookup). This is a part of D23247,
  which may skip the earlier VEXEC check as well if the root fd was opened
  with O_SEARCH.
  
  This one required slightly more work as zfs_lookup may also be called
  indirectly as VOP_LOOKUP or a couple of other places where we must do the
  check.

Modified:
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
  stable/11/sys/fs/pseudofs/pseudofs_vnops.c
Directory Properties:
  stable/11/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
  stable/12/sys/fs/pseudofs/pseudofs_vnops.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
==============================================================================
--- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c	Wed Feb  5 21:16:51 2020	(r357604)
+++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c	Wed Feb  5 21:30:31 2020	(r357605)
@@ -1525,7 +1525,7 @@ zfs_lookup_lock(vnode_t *dvp, vnode_t *vp, const char 
 /* ARGSUSED */
 static int
 zfs_lookup(vnode_t *dvp, char *nm, vnode_t **vpp, struct componentname *cnp,
-    int nameiop, cred_t *cr, kthread_t *td, int flags)
+    int nameiop, cred_t *cr, kthread_t *td, int flags, boolean_t cached)
 {
 	znode_t *zdp = VTOZ(dvp);
 	znode_t *zp;
@@ -1597,9 +1597,12 @@ zfs_lookup(vnode_t *dvp, char *nm, vnode_t **vpp, stru
 	/*
 	 * Check accessibility of directory.
 	 */
-	if (error = zfs_zaccess(zdp, ACE_EXECUTE, 0, B_FALSE, cr)) {
-		ZFS_EXIT(zfsvfs);
-		return (error);
+	if (!cached) {
+		error = zfs_zaccess(zdp, ACE_EXECUTE, 0, B_FALSE, cr);
+		if (error != 0) {
+			ZFS_EXIT(zfsvfs);
+			return (error);
+		}
 	}
 
 	if (zfsvfs->z_utf8 && u8_validate(nm, strlen(nm),
@@ -4941,12 +4944,7 @@ zfs_freebsd_access(ap)
 }
 
 static int
-zfs_freebsd_lookup(ap)
-	struct vop_lookup_args /* {
-		struct vnode *a_dvp;
-		struct vnode **a_vpp;
-		struct componentname *a_cnp;
-	} */ *ap;
+zfs_freebsd_lookup(struct vop_lookup_args *ap, boolean_t cached)
 {
 	struct componentname *cnp = ap->a_cnp;
 	char nm[NAME_MAX + 1];
@@ -4955,10 +4953,17 @@ zfs_freebsd_lookup(ap)
 	strlcpy(nm, cnp->cn_nameptr, MIN(cnp->cn_namelen + 1, sizeof(nm)));
 
 	return (zfs_lookup(ap->a_dvp, nm, ap->a_vpp, cnp, cnp->cn_nameiop,
-	    cnp->cn_cred, cnp->cn_thread, 0));
+	    cnp->cn_cred, cnp->cn_thread, 0, cached));
 }
 
 static int
+zfs_freebsd_cachedlookup(struct vop_cachedlookup_args *ap)
+{
+
+	return (zfs_freebsd_lookup((struct vop_lookup_args *)ap, B_TRUE));
+}
+
+static int
 zfs_cache_lookup(ap)
 	struct vop_lookup_args /* {
 		struct vnode *a_dvp;
@@ -4972,7 +4977,7 @@ zfs_cache_lookup(ap)
 	if (zfsvfs->z_use_namecache)
 		return (vfs_cache_lookup(ap));
 	else
-		return (zfs_freebsd_lookup(ap));
+		return (zfs_freebsd_lookup(ap, B_FALSE));
 }
 
 static int
@@ -5535,7 +5540,7 @@ vop_getextattr {
 	ZFS_ENTER(zfsvfs);
 
 	error = zfs_lookup(ap->a_vp, NULL, &xvp, NULL, 0, ap->a_cred, td,
-	    LOOKUP_XATTR);
+	    LOOKUP_XATTR, B_FALSE);
 	if (error != 0) {
 		ZFS_EXIT(zfsvfs);
 		return (error);
@@ -5604,7 +5609,7 @@ vop_deleteextattr {
 	ZFS_ENTER(zfsvfs);
 
 	error = zfs_lookup(ap->a_vp, NULL, &xvp, NULL, 0, ap->a_cred, td,
-	    LOOKUP_XATTR);
+	    LOOKUP_XATTR, B_FALSE);
 	if (error != 0) {
 		ZFS_EXIT(zfsvfs);
 		return (error);
@@ -5672,7 +5677,7 @@ vop_setextattr {
 	ZFS_ENTER(zfsvfs);
 
 	error = zfs_lookup(ap->a_vp, NULL, &xvp, NULL, 0, ap->a_cred, td,
-	    LOOKUP_XATTR | CREATE_XATTR_DIR);
+	    LOOKUP_XATTR | CREATE_XATTR_DIR, B_FALSE);
 	if (error != 0) {
 		ZFS_EXIT(zfsvfs);
 		return (error);
@@ -5749,7 +5754,7 @@ vop_listextattr {
 		*sizep = 0;
 
 	error = zfs_lookup(ap->a_vp, NULL, &xvp, NULL, 0, ap->a_cred, td,
-	    LOOKUP_XATTR);
+	    LOOKUP_XATTR, B_FALSE);
 	if (error != 0) {
 		ZFS_EXIT(zfsvfs);
 		/*
@@ -6007,7 +6012,7 @@ struct vop_vector zfs_vnodeops = {
 	.vop_reclaim =		zfs_freebsd_reclaim,
 	.vop_access =		zfs_freebsd_access,
 	.vop_lookup =		zfs_cache_lookup,
-	.vop_cachedlookup =	zfs_freebsd_lookup,
+	.vop_cachedlookup =	zfs_freebsd_cachedlookup,
 	.vop_getattr =		zfs_freebsd_getattr,
 	.vop_setattr =		zfs_freebsd_setattr,
 	.vop_create =		zfs_freebsd_create,

Modified: stable/11/sys/fs/pseudofs/pseudofs_vnops.c
==============================================================================
--- stable/11/sys/fs/pseudofs/pseudofs_vnops.c	Wed Feb  5 21:16:51 2020	(r357604)
+++ stable/11/sys/fs/pseudofs/pseudofs_vnops.c	Wed Feb  5 21:30:31 2020	(r357605)
@@ -446,10 +446,6 @@ pfs_lookup(struct vop_cachedlookup_args *va)
 		PFS_RETURN (ENOTDIR);
 	KASSERT_PN_IS_DIR(pd);
 
-	error = VOP_ACCESS(vn, VEXEC, cnp->cn_cred, cnp->cn_thread);
-	if (error)
-		PFS_RETURN (error);
-
 	/*
 	 * Don't support DELETE or RENAME.  CREATE is supported so
 	 * that O_CREAT will work, but the lookup will still fail if



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