diff options
author | Mickaël Salaün <mic@digikod.net> | 2022-05-06 19:08:14 +0300 |
---|---|---|
committer | Mickaël Salaün <mic@digikod.net> | 2022-05-23 14:27:49 +0300 |
commit | c56b3bf566da5a0dd3b58ad97a614b0928b06ebf (patch) | |
tree | 77e3781311bd7560b52972e93d8c84153510b274 /tools | |
parent | 291865bd7e8bb4b4033d341fa02dafa728e6378c (diff) | |
download | linux-c56b3bf566da5a0dd3b58ad97a614b0928b06ebf.tar.xz |
selftests/landlock: Add tests for unknown access rights
Make sure that trying to use unknown access rights returns an error.
Cc: Shuah Khan <shuah@kernel.org>
Link: https://lore.kernel.org/r/20220506160820.524344-5-mic@digikod.net
Cc: stable@vger.kernel.org
Signed-off-by: Mickaël Salaün <mic@digikod.net>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/testing/selftests/landlock/fs_test.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tools/testing/selftests/landlock/fs_test.c b/tools/testing/selftests/landlock/fs_test.c index cc7fa7b17578..f293b7e2a1a7 100644 --- a/tools/testing/selftests/landlock/fs_test.c +++ b/tools/testing/selftests/landlock/fs_test.c @@ -448,6 +448,22 @@ TEST_F_FORK(layout1, file_access_rights) ASSERT_EQ(0, close(path_beneath.parent_fd)); } +TEST_F_FORK(layout1, unknown_access_rights) +{ + __u64 access_mask; + + for (access_mask = 1ULL << 63; access_mask != ACCESS_LAST; + access_mask >>= 1) { + struct landlock_ruleset_attr ruleset_attr = { + .handled_access_fs = access_mask, + }; + + ASSERT_EQ(-1, landlock_create_ruleset(&ruleset_attr, + sizeof(ruleset_attr), 0)); + ASSERT_EQ(EINVAL, errno); + } +} + static void add_path_beneath(struct __test_metadata *const _metadata, const int ruleset_fd, const __u64 allowed_access, const char *const path) |