Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 23 Mar 2023 20:22:38 GMT
From:      Mateusz Guzik <mjg@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 276e405a50d3 - releng/13.2 - vfs cache: return ENOTDIR for not_a_dir/{.,..} lookups
Message-ID:  <202303232022.32NKMc1l070626@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch releng/13.2 has been updated by mjg:

URL: https://cgit.FreeBSD.org/src/commit/?id=276e405a50d36229df308642b30e6e66372d39f2

commit 276e405a50d36229df308642b30e6e66372d39f2
Author:     Mateusz Guzik <mjg@FreeBSD.org>
AuthorDate: 2023-03-23 19:19:48 +0000
Commit:     Mateusz Guzik <mjg@FreeBSD.org>
CommitDate: 2023-03-23 20:22:20 +0000

    vfs cache: return ENOTDIR for not_a_dir/{.,..} lookups
    
    Reported by:    Oliver Kiddle
    PR:     270419
    MFC:    3 days
    Approved by:    re (gjb)
    
    (cherry picked from commit c16c4ea6d399332d4a023df6e423be61fdb875a5)
    (cherry picked from commit 5d83656c09f522d6bf4f1050be60f270ddef04af)
---
 sys/kern/vfs_cache.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c
index e87f4a6cda1a..2b07dbbc34f0 100644
--- a/sys/kern/vfs_cache.c
+++ b/sys/kern/vfs_cache.c
@@ -5075,6 +5075,12 @@ cache_fplookup_dot(struct cache_fpl *fpl)
 	int error;
 
 	MPASS(!seqc_in_modify(fpl->dvp_seqc));
+
+	if (__predict_false(fpl->dvp->v_type != VDIR)) {
+		cache_fpl_smr_exit(fpl);
+		return (cache_fpl_handled_error(fpl, ENOTDIR));
+	}
+
 	/*
 	 * Just re-assign the value. seqc will be checked later for the first
 	 * non-dot path component in line and/or before deciding to return the
@@ -5137,6 +5143,11 @@ cache_fplookup_dotdot(struct cache_fpl *fpl)
 		return (cache_fpl_partial(fpl));
 	}
 
+	if (__predict_false(dvp->v_type != VDIR)) {
+		cache_fpl_smr_exit(fpl);
+		return (cache_fpl_handled_error(fpl, ENOTDIR));
+	}
+
 	ncp = atomic_load_consume_ptr(&dvp->v_cache_dd);
 	if (ncp == NULL) {
 		return (cache_fpl_aborted(fpl));



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