From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796381188; b=rlKVy0KG8gkacoGt/e/HhEZ8QoYlMBdRlvCXdTXd7uafFDmYWtS7cWrjRoy2nMG+vy0t QSAAx5vp4sjRSRrOrEK1+FHhfoIoGkuYrhiLkjaXvp89tM3Ol8f8Np+Mp0KPUTT6Et5Ij BZ8Qfab8U3Tp8TPebkcO0JxwdKFBhRvwW/euS2FLUHTu6sA1FC7RDuX6vXMqPqIvQNcOJ iLJz9y/fjSntj12oQNMJdgSHO6z1w0UUi3GbA3+Ll8LO9d7ooEecvLVdTkPB1+IKLDKcJ itgDXOkQUSpfzgK7vqZe2L/lxrpENqIILJErWEG59dKw0qzsMk64jMLh2+bk2DB1bSg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796381188; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=Qpn42PTTaSg4WCV43ARl8GNWKjVkx5Iz35v87X6VKxk=; b=3otEAxe61cSITVdLys2ZWToPFJMorW1mNYlxid42gC9Bd2GQRByiGCInuTlRabcFYmis 5qHTTA8ekPUxoka6CjaJKmTl4U+vf7NQFpZkJCNThrVD54W1Uk/TNNQtJLy3SLYrd0IbY CAmuPylWrPK1cg5RTZG3oeYi3NnccK5DwtIFkOYzb5h5qC6vLbrqR9onz96qOVIC8X+cQ PL8UiVoNQ4vYpdbxRG3X8DSWMZNnDAOHcjdvw1PekMEsl9o7AsUZaEbU240ElmpuqODn4 yR8yRCvZEYkr9/dqlwa+KkBI3r0GahdlW3jyVcDX8SGCT5xB03EqYilk/6b2HG8xrjA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=uG45qkyY; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 685E2606A33A; Fri, 4 Dec 2026 10:46:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=uG45qkyY Received: by smtp.kernel.org (Postfix) with ESMTPSA id D00101F0093B; Fri, 4 Dec 2026 10:46:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796381188; bh=Qpn42PTTaSg4WCV43ARl8GNWKjVkx5Iz35v87X6VKxk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=uG45qkyYce4rrlMssy1RsMfB0nT929o6cEV/wfpJCWFazvFTJ2YZQiMjtPNLbQLn0 uXkzJkVvr3KOuFS7UnAx9Hi6HVx2fE4EOgjMQB2+7uB2VrV5mxYsF84poGrWShTw/8 wvZt7QLdO+mgzDURZQatB/ZjX/VBv3bL5tJPcyTc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, =?UTF-8?q?G=C3=BCnther=20Noack?= , =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= Subject: [PATCH 7.3 597/742] selftests/landlock: Test that layering does not break refer Date: Fri, 4 Dec 2026 19:07:41 +0900 Message-ID: <20261204100650.981311628@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: 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 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Günther Noack commit 047e27306d268d6972f8242b69f50e5814b09282 upstream. Regression test to exercise that layered Landlock domains do not accidentally deny the LANDLOCK_ACCESS_FS_REFER access right. This used to be the case when layering a non-filesystem ruleset with a filesystem-enforcing ruleset. In that case, REFER operations that would have been allowed for the individual rulesets would get denied when layering the same rulesets. Link: https://github.com/landlock-lsm/linux/issues/67 Link: https://github.com/landlock-lsm/go-landlock/issues/66 Fixes: fff69fb03dde ("landlock: Support network rules with TCP bind and connect") Cc: stable@vger.kernel.org Signed-off-by: Günther Noack Link: https://patch.msgid.link/20261113-b4-landlock-refer-nonfs-layer-v3-3-02d7e42bcdfd@gmail.com Signed-off-by: Mickaël Salaün Signed-off-by: Greg Kroah-Hartman --- tools/testing/selftests/landlock/fs_test.c | 54 +++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) --- a/tools/testing/selftests/landlock/fs_test.c +++ b/tools/testing/selftests/landlock/fs_test.c @@ -2620,6 +2620,60 @@ TEST_F_FORK(layout1, refer_denied_by_def } /* + * Regression test for layered domains: The two enforced Landlock layers both do + * not restrict the tested "refer" operations on their own, so they should also + * not restrict them when they are layered, regardless of the layer order. + */ +static void test_layering_does_not_break_refer( + struct __test_metadata *const _metadata, + const struct landlock_ruleset_attr *const non_fs_attr, + const bool non_fs_first) +{ + ASSERT_EQ(0, unlink(file1_s1d2)); + + if (non_fs_first) + drop_access_rights(_metadata, non_fs_attr); + + enforce_fs(_metadata, LANDLOCK_ACCESS_FS_REFER, layer_dir_s1d1_refer); + + if (!non_fs_first) + drop_access_rights(_metadata, non_fs_attr); + + EXPECT_EQ(0, test_rename(file1_s1d1, file1_s1d2)); + EXPECT_EQ(0, test_rename(file1_s1d2, file1_s1d1)); + EXPECT_EQ(0, test_exchange(file2_s1d1, file2_s1d2)); + EXPECT_EQ(0, test_exchange(file2_s1d2, file2_s1d1)); +} + +static const struct landlock_ruleset_attr net_attr = { + .handled_access_net = LANDLOCK_ACCESS_NET_BIND_TCP, +}; + +static const struct landlock_ruleset_attr scoped_attr = { + .scoped = LANDLOCK_SCOPE_SIGNAL, +}; + +TEST_F_FORK(layout1, layering_fs_then_net_does_not_break_refer) +{ + test_layering_does_not_break_refer(_metadata, &net_attr, false); +} + +TEST_F_FORK(layout1, layering_net_then_fs_does_not_break_refer) +{ + test_layering_does_not_break_refer(_metadata, &net_attr, true); +} + +TEST_F_FORK(layout1, layering_fs_then_scoped_does_not_break_refer) +{ + test_layering_does_not_break_refer(_metadata, &scoped_attr, false); +} + +TEST_F_FORK(layout1, layering_scoped_then_fs_does_not_break_refer) +{ + test_layering_does_not_break_refer(_metadata, &scoped_attr, true); +} + +/* * Tests walking through a denied root mount. */ TEST_F_FORK(layout1, refer_mount_root_deny)