aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Evans <kevans@FreeBSD.org>2021-01-28 14:27:28 +0000
committerKyle Evans <kevans@FreeBSD.org>2021-01-29 01:25:11 +0000
commit0f919ed4ae4df082eefb517afe02752b1790afd3 (patch)
tree29757ea4eca916c4ed6eec462856a6ca13f92739
parent8a51f14a7833fd14e1f125e63a0af9d260dcd287 (diff)
downloadsrc-0f919ed4ae4df082eefb517afe02752b1790afd3.tar.gz
src-0f919ed4ae4df082eefb517afe02752b1790afd3.zip
tmpfs: push VEXEC check into tmpfs_lookup()
vfs_cache_lookup() has already done the appropriate VEXEC check, therefore we must not re-check in VOP_CACHEDLOOKUP. This fixes O_SEARCH semantics on tmpfs and removes a redundant descent into VOP_ACCESS() in the common case. Reported-by: arichardson (via CheriBSD Jenkins CI) Reviewed-by: kib MFC-after: 3 days Differential Revision: https://reviews.freebsd.org/D28401
-rw-r--r--sys/fs/tmpfs/tmpfs_vnops.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/sys/fs/tmpfs/tmpfs_vnops.c b/sys/fs/tmpfs/tmpfs_vnops.c
index 7614287c642e..7be2655dcf0b 100644
--- a/sys/fs/tmpfs/tmpfs_vnops.c
+++ b/sys/fs/tmpfs/tmpfs_vnops.c
@@ -91,14 +91,10 @@ tmpfs_lookup1(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp)
struct tmpfs_mount *tm;
int error;
+ /* Caller assumes responsibility for ensuring access (VEXEC). */
dnode = VP_TO_TMPFS_DIR(dvp);
*vpp = NULLVP;
- /* Check accessibility of requested node as a first step. */
- error = vn_dir_check_exec(dvp, cnp);
- if (error != 0)
- goto out;
-
/* We cannot be requesting the parent directory of the root node. */
MPASS(IMPLIES(dnode->tn_type == VDIR &&
dnode->tn_dir.tn_parent == dnode,
@@ -241,8 +237,17 @@ tmpfs_cached_lookup(struct vop_cachedlookup_args *v)
static int
tmpfs_lookup(struct vop_lookup_args *v)
{
+ struct vnode *dvp = v->a_dvp;
+ struct vnode **vpp = v->a_vpp;
+ struct componentname *cnp = v->a_cnp;
+ int error;
- return (tmpfs_lookup1(v->a_dvp, v->a_vpp, v->a_cnp));
+ /* Check accessibility of requested node as a first step. */
+ error = vn_dir_check_exec(dvp, cnp);
+ if (error != 0)
+ return (error);
+
+ return (tmpfs_lookup1(dvp, vpp, cnp));
}
static int