mirror of
https://github.com/torvalds/linux.git
synced 2026-05-24 23:22:31 +02:00
selftests/filesystems: add open() test for anonymous inodes
Test that anonymous inodes cannot be open()ed. Link: https://lore.kernel.org/20250407-work-anon_inode-v1-9-53a44c20d44e@kernel.org Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
parent
f8ca403ae7
commit
25a6cc9a63
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user