git: bb8ecf259f96 - main - vfs cache: Fallback to namei to resolve symlinks with leading / in target for non-native ABI

From: Dmitry Chagin <dchagin_at_FreeBSD.org>
Date: Thu, 19 Oct 2023 10:34:14 UTC
The branch main has been updated by dchagin:

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

commit bb8ecf259f96510b9c2146d846403393543061b7
Author:     Dmitry Chagin <dchagin@FreeBSD.org>
AuthorDate: 2023-10-19 10:33:58 +0000
Commit:     Dmitry Chagin <dchagin@FreeBSD.org>
CommitDate: 2023-10-19 10:33:58 +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
---
 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 99e293d5a873..4b51b3558739 100644
--- a/sys/kern/vfs_cache.c
+++ b/sys/kern/vfs_cache.c
@@ -5426,12 +5426,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) {
@@ -5487,6 +5489,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);
 }