git: 48caab76e520 - releng/15.2 - rbeneath lookup: do not allow to step up with dotdot lookup over VV_ROOT
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 17 Nov 2026 17:09:38 UTC
The branch releng/15.2 has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=48caab76e52002a88e2fc8a244f1eeda3a9c419f
commit 48caab76e52002a88e2fc8a244f1eeda3a9c419f
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-10-23 03:48:47 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2026-11-17 13:34:51 +0000
rbeneath lookup: do not allow to step up with dotdot lookup over VV_ROOT
In vfs_lookup(), the ".." loop steps from a mount root to
its mnt_vnodecovered vnode before the name is looked up.
nameicap_check_dotdot() runs only after VOP_LOOKUP() and compares the
directory being left, ni_dvp, with ni_rbeneath_dpp, the start. After
the mount crossing ni_dvp is the covered vnode, not the start, so the
comparison never matches and ".." is allowed. [*]
Before 2f60984053 the loop called nameicap_check_dotdot(ndp, dp) right
after the mnt_vnodecovered step, and the covered vnode, which was not
among the vnodes the lookup had visited, was refused. The change replaced
the visited-vnode tracking with the comparison against ni_rbeneath_dpp,
and removed that call.
A process restricted to a directory descriptor by Capsicum (capability
mode, or a descriptor limited with cap_rights_limit()), or a program that
relies on O_RESOLVE_BENEATH / AT_RESOLVE_BENEATH to keep a lookup beneath
a directory, is not contained when that directory is a mount root (for
example a tmpfs, nullfs or devfs mount handed to a sandbox). Through ".."
it can name anything reachable from the directory that holds the mount
point, within the descriptor's rights and the usual permission checks.
Sandboxes that are handed a mount root (a per-sandbox tmpfs is a common
pattern) lose their file-system boundary.
Similarly, if the ni_rbeneath_dpp is reclaimed and then re-instantiated,
e.g. for nocache nullfs or just by vnlru, the startdir might be bypassed
because the comparison would not hold. Check for doomed state to close
the possibility.
Approved by: re (cperciva)
Approved by: so
Security: FreeBSD-SA-26:81.vfs
Security: CVE-2026-101312
Reported by: pjd [*]
Fixes: 2f60984053e5 ("namei dotdot tracker: take mnt_renamelock shared to prevent parallel renames")
Sponsored by: The FreeBSD Foundation
---
sys/kern/vfs_lookup.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c
index 0a6e85d4f2ee..4ddf7d5433bf 100644
--- a/sys/kern/vfs_lookup.c
+++ b/sys/kern/vfs_lookup.c
@@ -931,6 +931,18 @@ vfs_lookup_isroot(struct nameidata *ndp, struct vnode *dvp)
dvp == rootvnode);
}
+static bool
+vfs_lookup_invalid_boundary(struct nameidata *ndp, struct vnode *dvp)
+{
+ struct vnode *ndpp;
+
+ ndpp = ndp->ni_rbeneath_dpp;
+ /* The doomed check prevents escape through the startdir reclaim. */
+ if (dvp == ndpp || (ndpp != NULL && VN_IS_DOOMED(ndpp)))
+ return (true);
+ return (vfs_lookup_isroot(ndp, dvp));
+}
+
/*
* FAILIFEXISTS handling.
*
@@ -1280,7 +1292,7 @@ dirloop:
for (;;) {
bool isroot;
- isroot = vfs_lookup_isroot(ndp, dp);
+ isroot = vfs_lookup_invalid_boundary(ndp, dp);
if (__predict_false(isroot && (ndp->ni_lcf &
(NI_LCF_STRICTREL | NI_LCF_STRICTREL_KTR)) != 0)) {
if ((ndp->ni_lcf & NI_LCF_STRICTREL_KTR) != 0)