diff options
| author | Christian Brauner <[email protected]> | 2025-04-07 09:54:23 +0000 |
|---|---|---|
| committer | Christian Brauner <[email protected]> | 2025-04-07 14:20:15 +0000 |
| commit | 25a6cc9a630b4b1b783903b23a3a97c5bf16bf41 (patch) | |
| tree | 458a10e38e817f8239cb3bd4e7fdc83a623b15a8 /tools/testing/selftests/filesystems/anon_inode_test.c | |
| parent | selftests/filesystems: add exec() test for anonymous inodes (diff) | |
| download | kernel-25a6cc9a630b4b1b783903b23a3a97c5bf16bf41.tar.gz kernel-25a6cc9a630b4b1b783903b23a3a97c5bf16bf41.zip | |
selftests/filesystems: add open() test for anonymous inodes
Test that anonymous inodes cannot be open()ed.
Link: https://lore.kernel.org/[email protected]
Reviewed-by: Jeff Layton <[email protected]>
Signed-off-by: Christian Brauner <[email protected]>
Diffstat (limited to 'tools/testing/selftests/filesystems/anon_inode_test.c')
| -rw-r--r-- | tools/testing/selftests/filesystems/anon_inode_test.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tools/testing/selftests/filesystems/anon_inode_test.c b/tools/testing/selftests/filesystems/anon_inode_test.c index 486496252ddd..e8e0ef1460d2 100644 --- a/tools/testing/selftests/filesystems/anon_inode_test.c +++ b/tools/testing/selftests/filesystems/anon_inode_test.c @@ -48,5 +48,22 @@ TEST(anon_inode_no_exec) EXPECT_EQ(close(fd_context), 0); } +TEST(anon_inode_no_open) +{ + int fd_context; + + fd_context = sys_fsopen("tmpfs", 0); + ASSERT_GE(fd_context, 0); + + ASSERT_GE(dup2(fd_context, 500), 0); + ASSERT_EQ(close(fd_context), 0); + fd_context = 500; + + ASSERT_LT(open("/proc/self/fd/500", 0), 0); + ASSERT_EQ(errno, ENXIO); + + EXPECT_EQ(close(fd_context), 0); +} + TEST_HARNESS_MAIN |
