@@ -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)
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@namei.org> Cc: Jann Horn <jannh@google.com> Cc: Serge E. Hallyn <serge@hallyn.com> Signed-off-by: Mickaël Salaün <mic@digikod.net> --- tools/testing/selftests/landlock/fs_test.c | 8 ++++++++ 1 file changed, 8 insertions(+)