[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed, 11 Nov 2020 22:34:39 +0100
From: Mickaël Salaün <mic@...ikod.net>
To: James Morris <jmorris@...ei.org>, Jann Horn <jannh@...gle.com>,
"Serge E . Hallyn" <serge@...lyn.com>
Cc: Mickaël Salaün <mic@...ikod.net>,
Shuah Khan <shuah@...nel.org>,
Vincent Dagonneau <vincent.dagonneau@....gouv.fr>,
linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-kselftest@...r.kernel.org,
linux-security-module@...r.kernel.org
Subject: [PATCH v1 6/9] selftests/landlock: Extend layout1.inherit_superset
These additional checks test that layers are handled as expected in the
superset use case, which complete the inherit_subset checks.
Cc: James Morris <jmorris@...ei.org>
Cc: Jann Horn <jannh@...gle.com>
Cc: Serge E. Hallyn <serge@...lyn.com>
Signed-off-by: Mickaël Salaün <mic@...ikod.net>
---
tools/testing/selftests/landlock/fs_test.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/tools/testing/selftests/landlock/fs_test.c b/tools/testing/selftests/landlock/fs_test.c
index 1885174b2770..c2f65034e4ee 100644
--- a/tools/testing/selftests/landlock/fs_test.c
+++ b/tools/testing/selftests/landlock/fs_test.c
@@ -907,6 +907,10 @@ TEST_F(layout1, inherit_superset)
open_fd = open(dir_s1d3, O_RDONLY | O_DIRECTORY | O_CLOEXEC);
ASSERT_LE(0, open_fd);
ASSERT_EQ(0, close(open_fd));
+ /* File access is allowed for file1_s1d3. */
+ open_fd = open(file1_s1d3, O_RDONLY | O_CLOEXEC);
+ ASSERT_LE(0, open_fd);
+ ASSERT_EQ(0, close(open_fd));
/* Now dir_s1d2, parent of dir_s1d3, gets a new rule tied to it. */
add_path_beneath(_metadata, ruleset_fd, LANDLOCK_ACCESS_FS_READ_FILE |
@@ -922,6 +926,10 @@ TEST_F(layout1, inherit_superset)
open_fd = open(dir_s1d3, O_RDONLY | O_DIRECTORY | O_CLOEXEC);
ASSERT_LE(0, open_fd);
ASSERT_EQ(0, close(open_fd));
+ /* File access is now denied for file1_s1d3. */
+ open_fd = open(file1_s1d3, O_RDONLY | O_CLOEXEC);
+ ASSERT_LE(-1, open_fd);
+ ASSERT_EQ(EACCES, errno);
}
TEST_F(layout1, max_layers)
--
2.29.2
Powered by blists - more mailing lists