git: 151a23fa79b2 - main - namei: disallow altroot for beneath lookups
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 20 Nov 2026 15:10:49 UTC
The branch main has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=151a23fa79b2a6047e60f65edf77e1634308a1fa
commit 151a23fa79b2a6047e60f65edf77e1634308a1fa
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-10-21 21:39:02 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-11-20 15:10:26 +0000
namei: disallow altroot for beneath lookups
Once namei_setup() has determined that the lookup is strictly relative,
set ni_rootdir to pwd_rdir and mark the lookup as already restarted,
which effectively disables restart on ENOENT.
This is done in namei_setup() and not in NDINIT(), because RBENEATH
might be set after NDINIT() by vn_open_cred() or inherited from
the dirfd in fgetvp_lookup(), and ISRESTARTED is cleared by
NDREINIT()/NDRESET().
Noted by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D60035
---
sys/kern/vfs_lookup.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c
index 114845a1d295..2efdbe3b4f11 100644
--- a/sys/kern/vfs_lookup.c
+++ b/sys/kern/vfs_lookup.c
@@ -453,6 +453,13 @@ namei_setup(struct nameidata *ndp, struct vnode **dpp, struct pwd **pwdp)
if (error == 0 && (ndp->ni_lcf & NI_LCF_STRICTREL) != 0) {
ndp->ni_rbeneath_dpp = *dpp;
vholdnz(*dpp);
+
+ /*
+ * Prevent use of the alternative root and restarting
+ * the lookup on ENOENT.
+ */
+ cnp->cn_flags |= ISRESTARTED;
+ ndp->ni_rootdir = pwd->pwd_rdir;
}
/*