linux/tools/testing/selftests/filesystems
Christian Brauner d943e68edc
selftests/filesystems: test O_TMPFILE creation on idmapped mounts
Add a regression test for the fsuidgid_has_mapping() check in
vfs_tmpfile().  It idmaps a detached tmpfs mount so that the
caller-visible id range [0, 10000) maps onto the on-disk range
[10000, 20000) and checks that:

  - a caller whose fsuid/fsgid fall outside that range cannot create an
    O_TMPFILE through the mount and gets -EOVERFLOW instead of an inode
    owned by (uid_t)-1;

  - a mapped caller can create an O_TMPFILE, link it into the namespace,
    and the ownership round-trips through the mount idmap: it is reported
    as 0 through the mount and stored as 10000 on the underlying tmpfs.

The test runs entirely as root and uses setfsuid()/setfsgid() to become
the unmapped caller, so it needs no helper user.  The layer directory is
world-writable so that an unmapped caller still clears the directory
permission check and reaches the fsuidgid_has_mapping() test.

Link: https://patch.msgid.link/20260615-work-idmapped-tmpfile-v1-2-754a94d81f83@kernel.org
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
2026-07-01 15:26:18 +02:00
..
binderfs selftests: complete kselftest include centralization 2025-11-27 14:24:31 -08:00
empty_mntns selftests/empty_mntns: fix wrong CLONE_EMPTY_MNTNS hex value in comment 2026-04-14 09:30:57 +02:00
epoll selftests/eventpoll: Add test for multiple waiters 2026-06-04 10:25:10 +02:00
eventfd selftests: complete kselftest include centralization 2025-11-27 14:24:31 -08:00
fat selftests/filesystems: Add six consecutive 'x' characters to mktemp 2023-08-16 10:10:39 -06:00
fsmount_ns selftests/fsmount_ns: add missing TARGETS and fix cap test 2026-04-14 09:31:07 +02:00
fuse selftests: complete kselftest include centralization 2025-11-27 14:24:31 -08:00
mount-notify selftests: complete kselftest include centralization 2025-11-27 14:24:31 -08:00
move_mount selftests/filesystems: add MOVE_MOUNT_BENEATH rootfs tests 2026-03-12 13:34:59 +01:00
nsfs selftests: fix mntns iteration selftests 2026-02-27 22:00:11 +01:00
open_tree_ns selftests: add FSMOUNT_NAMESPACE tests 2026-03-12 13:33:54 +01:00
openat2 selftests: openat2: port emptypath_test to kselftest harness 2026-05-21 15:33:48 +02:00
overlayfs selftests: complete kselftest include centralization 2025-11-27 14:24:31 -08:00
statmount selftests/statmount: remove duplicate wait_for_pid() 2026-04-14 09:30:31 +02:00
xattr selftests/xattr: test xattrs on various socket families 2026-03-02 11:06:43 +01:00
.gitignore selftests/filesystems: test O_TMPFILE creation on idmapped mounts 2026-07-01 15:26:18 +02:00
anon_inode_test.c kselftest/anon_inode: replace null pointers with empty arrays 2025-12-31 10:50:13 -07:00
devpts_pts.c selftests/filesystems: Assume that TIOCGPTPEER is defined 2026-03-02 11:08:20 +01:00
dnotify_test.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
fclog.c selftests: complete kselftest include centralization 2025-11-27 14:24:31 -08:00
file_stressor.c selftests: complete kselftest include centralization 2025-11-27 14:24:31 -08:00
idmapped_tmpfile.c selftests/filesystems: test O_TMPFILE creation on idmapped mounts 2026-07-01 15:26:18 +02:00
kernfs_test.c selftests: complete kselftest include centralization 2025-11-27 14:24:31 -08:00
Makefile selftests/filesystems: test O_TMPFILE creation on idmapped mounts 2026-07-01 15:26:18 +02:00
utils.c selftests/filesystems: add tests for empty mount namespaces 2026-03-12 13:33:55 +01:00
utils.h selftests/filesystems: add tests for empty mount namespaces 2026-03-12 13:33:55 +01:00
wrappers.h selftests/pidfd: move syscall definitions into wrappers.h 2025-05-12 11:40:12 +02:00