From owner-svn-src-stable-11@freebsd.org Wed Feb 5 21:30:32 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 528AE22F82B; Wed, 5 Feb 2020 21:30:32 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48CZVJ1ZzYz4CkZ; Wed, 5 Feb 2020 21:30:32 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2F0E79132; Wed, 5 Feb 2020 21:30:32 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 015LUWfT032741; Wed, 5 Feb 2020 21:30:32 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 015LUVAE032739; Wed, 5 Feb 2020 21:30:31 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <202002052130.015LUVAE032739@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Wed, 5 Feb 2020 21:30:31 +0000 (UTC) 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 X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: 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 X-SVN-Commit-Revision: 357605 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Feb 2020 21:30:32 -0000 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