From nobody Tue Nov 17 17:01:46 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4jTWGy6HW4z71QDd for ; Tue, 17 Nov 2026 17:01:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jTWGy4TCCz3Pl2 for ; Tue, 17 Nov 2026 17:01:46 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794934906; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=bA2/7G7JdX8z3eIPoogKKUqthRxVw8jtEL1or0woAhI=; b=fZEMkn9NSBSmFD8OF8YLVgUXz3v7OakE2etSqIKa4wtnR8PQTlUlYTZZw4JfmRvphcdxxA RtS4aajQB3G29qhdmCoiqd1D4K4J5vq+bFMJC/3QAqEfHKjBb/FdOzxd0p2sg2DeriUjmg uffJrVhQpyj4BJUexdrDUWtXFIjfscw0rTNmwkL1RpJI2nv0yAew20KF90Rd48KomrCmKY dW3WbPUqJqD44cu1BvYsFI+hUadfD3pFXKkQregHttr+ivtycfumkmE+L9aLjPtq28UnH7 4z5/vazZpvgO7F3YVCmIYumcTCqH8ntJJgAsCLm1lu0lJ8O395YbX+aBgsqOAg== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794934906; b=I+4ab3uT9I6LKk0nkWMWoRGmEWwMZY1OORsv20FJmuxtGxC8axelCOVpkKIgTGpCWB3NmI ITU041mcOiYdRIjfXMaPyTmzxU4DdW2UvtoKaxicPRiyLQZUrViEeBcFEmsdeoVh0/S6FX CkPWAcUxnqEr2cLRwbHyRz+svOVbmUPZbA8lH4XL8CmKJNETAcDPF/Sdqesj16a/eS1vkS AvHABpPDvfvXcOY8TVmqG+t5JVnOS69LUQ6s4/2ul5KNU8vX+bLLu0g6XTWCJi28P+FWx/ 8eE56u5WNZHiEBRZQP3R+/zZZKKg96TwyEijdM1nUP/6T1aelnF6v5rb3oOX5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794934906; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=bA2/7G7JdX8z3eIPoogKKUqthRxVw8jtEL1or0woAhI=; b=FNIJ8ljJl8uFhpTDTso+vMB2L1eTR3JwSv50ECAtlbX5SmZFidwBxZBLk7toHQoLKvR9ID nH3oYp0mEEkrmcWUcq0jpiRsL/dD53wHVx06EFH/magZmrSfq4bPjmwYU+RaaEZrSAavaH wkqWFje55Ls3NbrhhXAw4dxqJE3xTGiJ5DfPvBTLaCPARkqgdw26T4vrESDU2enXbwsH0S IEn2T+9Q2a0MTBhC6XOgTJLYLFfs7ADTi42QPYIyv0GLj3b6ImH7oufeB1/d/x0BWhxKVt HnKjPmV77AaVdJgaekZZq4GGDHooJ47eboJGuFfXMQS1ySwBbJ9IKg+TnrursA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jTWGy3qMszrLP for ; Tue, 17 Nov 2026 17:01:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1f011 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 17 Nov 2026 17:01:46 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Cc: Pawel Jakub Dawidek From: Mark Johnston Subject: git: 6e18212d43da - main - lookup_cap_dotdot test: check dotdot VV_ROOT escape List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6e18212d43da7f2884565558384d12217d1cf316 Auto-Submitted: auto-generated Date: Tue, 17 Nov 2026 17:01:46 +0000 Message-Id: <6afc887a.1f011.4989a8e6@gitrepo.freebsd.org> The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=6e18212d43da7f2884565558384d12217d1cf316 commit 6e18212d43da7f2884565558384d12217d1cf316 Author: Pawel Jakub Dawidek AuthorDate: 2026-10-23 04:01:41 +0000 Commit: Mark Johnston CommitDate: 2026-11-17 16:57:00 +0000 lookup_cap_dotdot test: check dotdot VV_ROOT escape Approved by: so Security: FreeBSD-SA-26:81.vfs --- tests/sys/vfs/lookup_cap_dotdot.c | 71 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/tests/sys/vfs/lookup_cap_dotdot.c b/tests/sys/vfs/lookup_cap_dotdot.c index fa26a13568ca..08c3f81b0d57 100644 --- a/tests/sys/vfs/lookup_cap_dotdot.c +++ b/tests/sys/vfs/lookup_cap_dotdot.c @@ -26,8 +26,10 @@ #include #include +#include #include #include +#include #include #include @@ -255,6 +257,74 @@ ATF_TC_BODY(lookup_cap_dotdot__root, tc) ATF_REQUIRE_ERRNO(ENOTCAPABLE, openat(dfd, "..", O_DIRECTORY)); } +/* + * ".." from a directory that is a mount root: the lookup must not cross + * to the covered vnode and leave its starting directory. + */ +static char mntpath[MAXPATHLEN]; + +static void +mount_tmpfs(void) +{ + struct iovec iov[4]; + char cwd[MAXPATHLEN]; + + ATF_REQUIRE(getcwd(cwd, sizeof(cwd)) != NULL); + snprintf(mntpath, sizeof(mntpath), "%s/mnt", cwd); + ATF_REQUIRE(mkdir(mntpath, 0777) == 0); + iov[0].iov_base = __DECONST(char *, "fstype"); + iov[0].iov_len = sizeof("fstype"); + iov[1].iov_base = __DECONST(char *, "tmpfs"); + iov[1].iov_len = sizeof("tmpfs"); + iov[2].iov_base = __DECONST(char *, "fspath"); + iov[2].iov_len = sizeof("fspath"); + iov[3].iov_base = mntpath; + iov[3].iov_len = strlen(mntpath) + 1; + ATF_REQUIRE_MSG(nmount(iov, nitems(iov), 0) == 0, "nmount: %s", + strerror(errno)); +} + +ATF_TC_WITH_CLEANUP(lookup_cap_dotdot__mountroot); +ATF_TC_HEAD(lookup_cap_dotdot__mountroot, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Validate that .. from a mount root stays beneath it"); + atf_tc_set_md_var(tc, "require.user", "root"); +} + +ATF_TC_BODY(lookup_cap_dotdot__mountroot, tc) +{ + int dfd; + + check_capsicum(); + mount_tmpfs(); + + ATF_REQUIRE((dfd = open(mntpath, O_RDONLY | O_DIRECTORY)) >= 0); + ATF_REQUIRE(mkdirat(dfd, "sub", 0777) == 0); + + /* A ".." that ends at the start is fine. */ + ATF_REQUIRE_MSG(openat(dfd, "sub/..", O_RDONLY | O_DIRECTORY | + O_RESOLVE_BENEATH) >= 0, "%s", strerror(errno)); + + ATF_REQUIRE_ERRNO(ENOTCAPABLE, openat(dfd, "..", O_RDONLY | + O_DIRECTORY | O_RESOLVE_BENEATH) < 0); + + ATF_REQUIRE(cap_enter() >= 0); + + ATF_REQUIRE_ERRNO(ENOTCAPABLE, + openat(dfd, "..", O_RDONLY | O_DIRECTORY) < 0); +} + +ATF_TC_CLEANUP(lookup_cap_dotdot__mountroot, tc) +{ + char cwd[MAXPATHLEN]; + + if (getcwd(cwd, sizeof(cwd)) == NULL) + return; + snprintf(mntpath, sizeof(mntpath), "%s/mnt", cwd); + (void)unmount(mntpath, MNT_FORCE); +} + ATF_TP_ADD_TCS(tp) { @@ -267,6 +337,7 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, lookup_cap_dotdot__advanced); ATF_TP_ADD_TC(tp, lookup_cap_dotdot__negative); ATF_TP_ADD_TC(tp, lookup_cap_dotdot__root); + ATF_TP_ADD_TC(tp, lookup_cap_dotdot__mountroot); return (atf_no_error()); }