Skip to content

Commit f8ca403

Browse files
committed
selftests/filesystems: add exec() test for anonymous inodes
Test that anonymous inodes cannot be exec()ed. Link: https://lore.kernel.org/[email protected] Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent fcf31ec commit f8ca403

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tools/testing/selftests/filesystems/anon_inode_test.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,18 @@ TEST(anon_inode_no_chmod)
3535
EXPECT_EQ(close(fd_context), 0);
3636
}
3737

38+
TEST(anon_inode_no_exec)
39+
{
40+
int fd_context;
41+
42+
fd_context = sys_fsopen("tmpfs", 0);
43+
ASSERT_GE(fd_context, 0);
44+
45+
ASSERT_LT(execveat(fd_context, "", NULL, NULL, AT_EMPTY_PATH), 0);
46+
ASSERT_EQ(errno, EACCES);
47+
48+
EXPECT_EQ(close(fd_context), 0);
49+
}
50+
3851
TEST_HARNESS_MAIN
3952

0 commit comments

Comments
 (0)