Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 1 Feb 2021 12:40:59 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: 569ac576088b - stable/13 - cache: add missing MNT_NOSYMFOLLOW check to symlink traversal
Message-ID:  <202102011240.111CextL098336@gitrepo.freebsd.org>

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

URL: https://cgit.FreeBSD.org/src/commit/?id=569ac576088bdb44856d5992ecdc647483b0970b

commit 569ac576088bdb44856d5992ecdc647483b0970b
Author:     Mateusz Guzik <mjg@FreeBSD.org>
AuthorDate: 2021-01-27 14:59:53 +0000
Commit:     Mateusz Guzik <mjg@FreeBSD.org>
CommitDate: 2021-02-01 12:39:18 +0000

    cache: add missing MNT_NOSYMFOLLOW check to symlink traversal
    
    (cherry picked from commit 5c325977b1138828367f39a3f2034af24c3654f0)
---
 sys/kern/vfs_cache.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c
index be06a2edc58b..ff8aad14001b 100644
--- a/sys/kern/vfs_cache.c
+++ b/sys/kern/vfs_cache.c
@@ -4816,6 +4816,7 @@ cache_symlink_resolve(struct cache_fpl *fpl, const char *string, size_t len)
 static int __noinline
 cache_fplookup_symlink(struct cache_fpl *fpl)
 {
+	struct mount *mp;
 	struct nameidata *ndp;
 	struct componentname *cnp;
 	struct vnode *dvp, *tvp;
@@ -4832,6 +4833,20 @@ cache_fplookup_symlink(struct cache_fpl *fpl)
 		}
 	}
 
+	mp = atomic_load_ptr(&dvp->v_mount);
+	if (__predict_false(mp == NULL)) {
+		return (cache_fpl_aborted(fpl));
+	}
+
+	/*
+	 * Note this check races against setting the flag just like regular
+	 * lookup.
+	 */
+	if (__predict_false((mp->mnt_flag & MNT_NOSYMFOLLOW) != 0)) {
+		cache_fpl_smr_exit(fpl);
+		return (cache_fpl_handled_error(fpl, EACCES));
+	}
+
 	error = VOP_FPLOOKUP_SYMLINK(tvp, fpl);
 	if (__predict_false(error != 0)) {
 		switch (error) {



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