git: b84a836ef02d - stable/14 - vfs cache: Fallback to namei to resolve symlinks with leading / in target for non-native ABI

From: Dmitry Chagin <dchagin_at_FreeBSD.org>
Date: Sun, 22 Oct 2023 06:56:05 UTC
The branch stable/14 has been updated by dchagin:

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

commit b84a836ef02de42e262ce44d46c859be288df4b0
Author:     Dmitry Chagin <dchagin@FreeBSD.org>
AuthorDate: 2023-10-19 10:33:58 +0000
Commit:     Dmitry Chagin <dchagin@FreeBSD.org>
CommitDate: 2023-10-22 06:55:53 +0000

    vfs cache: Fallback to namei to resolve symlinks with leading / in target for non-native ABI
    
    This is a temporary solution to fix PR before release.
    During 15.0 it's necessary to refactor symlinks handling
    between vfs & namecache.
    
    PR:                     273414
    Reported by:            Vincent Milum Jr, Dan Kotowski, glebius
    Tested by:              Dan Kotowski, glebius
    Reviewed by:
    Differential Revision:  https://reviews.freebsd.org/D41806
    MFC after:              3 days
    
    (cherry picked from commit bb8ecf259f96510b9c2146d846403393543061b7)
---
 sys/kern/vfs_cache.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c
index 115d0bdd3993..8917666950c1 100644
--- a/sys/kern/vfs_cache.c
+++ b/sys/kern/vfs_cache.c
@@ -5337,12 +5337,14 @@ cache_fplookup_symlink(struct cache_fpl *fpl)
 	struct nameidata *ndp;
 	struct componentname *cnp;
 	struct vnode *dvp, *tvp;
+	struct pwd *pwd;
 	int error;
 
 	ndp = fpl->ndp;
 	cnp = fpl->cnp;
 	dvp = fpl->dvp;
 	tvp = fpl->tvp;
+	pwd = *(fpl->pwd);
 
 	if (cache_fpl_islastcn(ndp)) {
 		if ((cnp->cn_flags & FOLLOW) == 0) {
@@ -5398,6 +5400,9 @@ cache_fplookup_symlink(struct cache_fpl *fpl)
 			cache_fpl_checkpoint(fpl);
 			return (cache_fpl_partial(fpl));
 		}
+		if (__predict_false(pwd->pwd_adir != pwd->pwd_rdir)) {
+			return (cache_fpl_aborted(fpl));
+		}
 	}
 	return (0);
 }