diff options
| author | 2025-04-07 11:54:22 +0200 | |
|---|---|---|
| committer | 2025-04-07 16:20:14 +0200 | |
| commit | f8ca403ae77cbfb4bf0fcd92c74075886f5f4aa8 (patch) | |
| tree | 10af003d863ad1051e8229f2de07226c1e566c57 /tools/testing/selftests/filesystems/anon_inode_test.c | |
| parent | selftests/filesystems: add chmod() test for anonymous inodes (diff) | |
| download | wireguard-linux-f8ca403ae77cbfb4bf0fcd92c74075886f5f4aa8.tar.xz wireguard-linux-f8ca403ae77cbfb4bf0fcd92c74075886f5f4aa8.zip | |
selftests/filesystems: add exec() test for anonymous inodes
Test that anonymous inodes cannot be exec()ed.
Link: https://lore.kernel.org/20250407-work-anon_inode-v1-8-53a44c20d44e@kernel.org
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'tools/testing/selftests/filesystems/anon_inode_test.c')
| -rw-r--r-- | tools/testing/selftests/filesystems/anon_inode_test.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tools/testing/selftests/filesystems/anon_inode_test.c b/tools/testing/selftests/filesystems/anon_inode_test.c index 7c4d0a225363..486496252ddd 100644 --- a/tools/testing/selftests/filesystems/anon_inode_test.c +++ b/tools/testing/selftests/filesystems/anon_inode_test.c @@ -35,5 +35,18 @@ TEST(anon_inode_no_chmod) EXPECT_EQ(close(fd_context), 0); } +TEST(anon_inode_no_exec) +{ + int fd_context; + + fd_context = sys_fsopen("tmpfs", 0); + ASSERT_GE(fd_context, 0); + + ASSERT_LT(execveat(fd_context, "", NULL, NULL, AT_EMPTY_PATH), 0); + ASSERT_EQ(errno, EACCES); + + EXPECT_EQ(close(fd_context), 0); +} + TEST_HARNESS_MAIN |
