]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
selftests/filesystems: add chmod() test for anonymous inodes
authorChristian Brauner <brauner@kernel.org>
Mon, 7 Apr 2025 09:54:21 +0000 (11:54 +0200)
committerChristian Brauner <brauner@kernel.org>
Mon, 7 Apr 2025 14:20:14 +0000 (16:20 +0200)
Test that anonymous inodes cannot be chmod()ed.

Link: https://lore.kernel.org/20250407-work-anon_inode-v1-7-53a44c20d44e@kernel.org
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>
tools/testing/selftests/filesystems/anon_inode_test.c

index f2cae8f1ccaee19e6976de8872f2f08c807e7d97..7c4d0a225363f993f37d547002a0332a98e23da2 100644 (file)
@@ -22,5 +22,18 @@ TEST(anon_inode_no_chown)
        EXPECT_EQ(close(fd_context), 0);
 }
 
+TEST(anon_inode_no_chmod)
+{
+       int fd_context;
+
+       fd_context = sys_fsopen("tmpfs", 0);
+       ASSERT_GE(fd_context, 0);
+
+       ASSERT_LT(fchmod(fd_context, 0777), 0);
+       ASSERT_EQ(errno, EOPNOTSUPP);
+
+       EXPECT_EQ(close(fd_context), 0);
+}
+
 TEST_HARNESS_MAIN