Skip to content

Commit d1788ad

Browse files
committed
selftests/landlock: Add tests for O_PATH
The O_PATH flag is currently not handled by Landlock. Let's make sure this behavior will remain consistent with the same ruleset over time. Cc: Shuah Khan <shuah@kernel.org> Link: https://lore.kernel.org/r/20220506160820.524344-8-mic@digikod.net Cc: stable@vger.kernel.org Signed-off-by: Mickaël Salaün <mic@digikod.net>
1 parent 6a1bdd4 commit d1788ad

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

tools/testing/selftests/landlock/fs_test.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -654,17 +654,23 @@ TEST_F_FORK(layout1, effective_access)
654654
enforce_ruleset(_metadata, ruleset_fd);
655655
ASSERT_EQ(0, close(ruleset_fd));
656656

657-
/* Tests on a directory. */
657+
/* Tests on a directory (with or without O_PATH). */
658658
ASSERT_EQ(EACCES, test_open("/", O_RDONLY));
659+
ASSERT_EQ(0, test_open("/", O_RDONLY | O_PATH));
659660
ASSERT_EQ(EACCES, test_open(dir_s1d1, O_RDONLY));
661+
ASSERT_EQ(0, test_open(dir_s1d1, O_RDONLY | O_PATH));
660662
ASSERT_EQ(EACCES, test_open(file1_s1d1, O_RDONLY));
663+
ASSERT_EQ(0, test_open(file1_s1d1, O_RDONLY | O_PATH));
664+
661665
ASSERT_EQ(0, test_open(dir_s1d2, O_RDONLY));
662666
ASSERT_EQ(0, test_open(file1_s1d2, O_RDONLY));
663667
ASSERT_EQ(0, test_open(dir_s1d3, O_RDONLY));
664668
ASSERT_EQ(0, test_open(file1_s1d3, O_RDONLY));
665669

666-
/* Tests on a file. */
670+
/* Tests on a file (with or without O_PATH). */
667671
ASSERT_EQ(EACCES, test_open(dir_s2d2, O_RDONLY));
672+
ASSERT_EQ(0, test_open(dir_s2d2, O_RDONLY | O_PATH));
673+
668674
ASSERT_EQ(0, test_open(file1_s2d2, O_RDONLY));
669675

670676
/* Checks effective read and write actions. */

0 commit comments

Comments
 (0)