mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-02-17 00:46:26 -05:00
selftests/filesystems: add chown() test for anonymous inodes
Test that anonymous inodes cannot be chown()ed. Link: https://lore.kernel.org/20250407-work-anon_inode-v1-6-53a44c20d44e@kernel.org Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
@@ -2,3 +2,4 @@
|
||||
dnotify_test
|
||||
devpts_pts
|
||||
file_stressor
|
||||
anon_inode_test
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
CFLAGS += $(KHDR_INCLUDES)
|
||||
TEST_GEN_PROGS := devpts_pts file_stressor
|
||||
TEST_GEN_PROGS := devpts_pts file_stressor anon_inode_test
|
||||
TEST_GEN_PROGS_EXTENDED := dnotify_test
|
||||
|
||||
include ../lib.mk
|
||||
|
||||
26
tools/testing/selftests/filesystems/anon_inode_test.c
Normal file
26
tools/testing/selftests/filesystems/anon_inode_test.c
Normal file
@@ -0,0 +1,26 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
#define _GNU_SOURCE
|
||||
#define __SANE_USERSPACE_TYPES__
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "../kselftest_harness.h"
|
||||
#include "overlayfs/wrappers.h"
|
||||
|
||||
TEST(anon_inode_no_chown)
|
||||
{
|
||||
int fd_context;
|
||||
|
||||
fd_context = sys_fsopen("tmpfs", 0);
|
||||
ASSERT_GE(fd_context, 0);
|
||||
|
||||
ASSERT_LT(fchown(fd_context, 1234, 5678), 0);
|
||||
ASSERT_EQ(errno, EOPNOTSUPP);
|
||||
|
||||
EXPECT_EQ(close(fd_context), 0);
|
||||
}
|
||||
|
||||
TEST_HARNESS_MAIN
|
||||
|
||||
Reference in New Issue
Block a user