From nobody Tue Apr 25 14:08:27 2023 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 4Q5P3w075Rz47FJ2; Tue, 25 Apr 2023 14:08:28 +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 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Q5P3v6nBGz3GQX; Tue, 25 Apr 2023 14:08:27 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1682431707; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/FCWDroi4gI5rNAcquPWr4GjMG1ZfeO0NcA8LufXPT8=; b=oJCzYlq7kIkM0y3aXEYcO4pqx/IZ7fso1DIYJ77oMv/lTeJp8MPqDB7cd3vtAoH078UEs6 QC58SNHrkUtFdAEGSTQwr4xySuzIkLlWhJP1jDfd+OFfDg7t5ou4574ElRgc0mwIgHMyR2 EOZEZHgu6iCDylP8xmZXVjexH7TkIubw5dGsj8n0dKFQFpv12qzw+pxJWkRv7IwVX7G/Bm TPohYfR5oZzYPU7z0gqz8+x6hmK7Fpd392FZQwTM2gS8rW5Pq6TjnYR9kvpWSB4kUtxWZz Tgdd92xeaJgBaiaS43MfV4SbC1cxtEuJrBev8Y+W+A8edjDfutIxcMkHjM8uRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1682431707; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/FCWDroi4gI5rNAcquPWr4GjMG1ZfeO0NcA8LufXPT8=; b=hu84k1IiDreXrB7jQtvWfc/u5GUgcwB+4VtQCQad/hqs+BxMsbxp7AN3sf6R1xmgFZ5ng9 yy2q3jQBNkBIDXQ0AyW6rJYYY8jlPgHWUCEbYYqi8xOQFCm9lvUrj5PQJrUaFtzxnJ73aj fLkD8ZmgVxIPVYs/OYQgjSEs+D8lL1H8B9e2ofdMgcBB6w/RKSFsld9NB1RFLuTE4DzFv0 SULqHHeLVatjK02Sc1pxrVMcjeXg/AoSnzjwEv0In2oTPpxAqajXj3zoy0EMu4cniwlETZ JsfAqecy4TTAFnNpLG9b99ZFVwVNztsPyUpww5CR4KXi2ChGwxXwHzg8sXfAeQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1682431708; a=rsa-sha256; cv=none; b=TH7ulFcMQTzcJW56YxoY7HwSm0n0+0QcQwxeafL3gvDgWIxELcP2f6gFXHOrHGO3qcbXu1 DNT2rLRR6mkiXvL8X80IlhVGB8xwZAdhTTJS+VYbx6PYn6HE+dSjGZy2cnH9AZErEyIjZg IbqninrI74gYccAzi0gwN7qTg5GrZ6XQBpP1Xb3oFla1pLRz4NZrotuGvsZtK7SnQSDHYp 0vCYYOo/Kz2yYZZRjEGY3ABqovfqZNrkUbCbEw0PyIYhqNMDG235VrMjwcZ2SaacoJJZd4 2vbo+rtR/Xl6UiubG9onvcRPee0mO5OmOeIlToLYI9+rTmC3Mc6RShy3tyA3xw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Q5P3v5sScz19Gl; Tue, 25 Apr 2023 14:08:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 33PE8RGi094392; Tue, 25 Apr 2023 14:08:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 33PE8Rsx094391; Tue, 25 Apr 2023 14:08:27 GMT (envelope-from git) Date: Tue, 25 Apr 2023 14:08:27 GMT Message-Id: <202304251408.33PE8Rsx094391@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 2d252934da51 - main - capsicum: Verify that openat("/", "..") fails with ENOTCAPABLE List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org 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: 2d252934da51a4857662d3ae0e9d81c8f2833ff3 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=2d252934da51a4857662d3ae0e9d81c8f2833ff3 commit 2d252934da51a4857662d3ae0e9d81c8f2833ff3 Author: Mark Johnston AuthorDate: 2023-04-25 13:54:47 +0000 Commit: Mark Johnston CommitDate: 2023-04-25 13:54:47 +0000 capsicum: Verify that openat("/", "..") fails with ENOTCAPABLE Add a regression test for a718431c30a5 ("lookup(): ensure that openat("/", "..", O_RESOLVE_BENEATH) fails"). MFC after: 1 week Sponsored by: The FreeBSD Foundation --- tests/sys/vfs/lookup_cap_dotdot.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/sys/vfs/lookup_cap_dotdot.c b/tests/sys/vfs/lookup_cap_dotdot.c index e023a50f8152..916129f7067f 100644 --- a/tests/sys/vfs/lookup_cap_dotdot.c +++ b/tests/sys/vfs/lookup_cap_dotdot.c @@ -233,6 +233,31 @@ ATF_TC_BODY(lookup_cap_dotdot__negative, tc) ATF_REQUIRE_ERRNO(ENOTCAPABLE, openat(dirfd, "../testdir/d1/f1", O_RDONLY) < 0); } +ATF_TC(lookup_cap_dotdot__root); +ATF_TC_HEAD(lookup_cap_dotdot__root, tc) +{ + atf_tc_set_md_var(tc, "descr", "Validate cap-mode /.. lookup fails"); +} + +ATF_TC_BODY(lookup_cap_dotdot__root, tc) +{ + int dfd, dfd2; + + check_capsicum(); + + dfd = open("/", O_DIRECTORY); + ATF_REQUIRE(dfd >= 0); + + dfd2 = openat(dfd, "..", O_DIRECTORY); + ATF_REQUIRE(dfd2 >= 0); + ATF_REQUIRE(close(dfd2) == 0); + + ATF_REQUIRE(cap_enter() >= 0); + + dfd2 = openat(dfd, "..", O_DIRECTORY); + ATF_REQUIRE_ERRNO(ENOTCAPABLE, openat(dfd, "..", O_DIRECTORY)); +} + ATF_TP_ADD_TCS(tp) { @@ -244,6 +269,7 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, lookup_cap_dotdot__basic); 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); return (atf_no_error()); }