linux-stable/tools/testing/selftests
Linus Torvalds b5683a37c8 vfs-6.9.pidfd
-----BEGIN PGP SIGNATURE-----
 
 iHUEABYKAB0WIQRAhzRXHqcMeLMyaSiRxhvAZXjcogUCZem4/wAKCRCRxhvAZXjc
 opnBAQCaQWwxjT0VLHebPniw6tel/KYlZ9jH9kBQwLrk1pembwEA+BsCY2C8YS4a
 75v9jOPxr+Z8j1SjxwwubcONPyqYXwQ=
 =+Wa3
 -----END PGP SIGNATURE-----

Merge tag 'vfs-6.9.pidfd' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs

Pull pdfd updates from Christian Brauner:

 - Until now pidfds could only be created for thread-group leaders but
   not for threads. There was no technical reason for this. We simply
   had no users that needed support for this. Now we do have users that
   need support for this.

   This introduces a new PIDFD_THREAD flag for pidfd_open(). If that
   flag is set pidfd_open() creates a pidfd that refers to a specific
   thread.

   In addition, we now allow clone() and clone3() to be called with
   CLONE_PIDFD | CLONE_THREAD which wasn't possible before.

   A pidfd that refers to an individual thread differs from a pidfd that
   refers to a thread-group leader:

    (1) Pidfds are pollable. A task may poll a pidfd and get notified
        when the task has exited.

        For thread-group leader pidfds the polling task is woken if the
        thread-group is empty. In other words, if the thread-group
        leader task exits when there are still threads alive in its
        thread-group the polling task will not be woken when the
        thread-group leader exits but rather when the last thread in the
        thread-group exits.

        For thread-specific pidfds the polling task is woken if the
        thread exits.

    (2) Passing a thread-group leader pidfd to pidfd_send_signal() will
        generate thread-group directed signals like kill(2) does.

        Passing a thread-specific pidfd to pidfd_send_signal() will
        generate thread-specific signals like tgkill(2) does.

        The default scope of the signal is thus determined by the type
        of the pidfd.

        Since use-cases exist where the default scope of the provided
        pidfd needs to be overriden the following flags are added to
        pidfd_send_signal():

         - PIDFD_SIGNAL_THREAD
           Send a thread-specific signal.

         - PIDFD_SIGNAL_THREAD_GROUP
           Send a thread-group directed signal.

         - PIDFD_SIGNAL_PROCESS_GROUP
           Send a process-group directed signal.

        The scope change will only work if the struct pid is actually
        used for this scope.

        For example, in order to send a thread-group directed signal the
        provided pidfd must be used as a thread-group leader and
        similarly for PIDFD_SIGNAL_PROCESS_GROUP the struct pid must be
        used as a process group leader.

 - Move pidfds from the anonymous inode infrastructure to a tiny pseudo
   filesystem. This will unblock further work that we weren't able to do
   simply because of the very justified limitations of anonymous inodes.
   Moving pidfds to a tiny pseudo filesystem allows for statx on pidfds
   to become useful for the first time. They can now be compared by
   inode number which are unique for the system lifetime.

   Instead of stashing struct pid in file->private_data we can now stash
   it in inode->i_private. This makes it possible to introduce concepts
   that operate on a process once all file descriptors have been closed.
   A concrete example is kill-on-last-close. Another side-effect is that
   file->private_data is now freed up for per-file options for pidfds.

   Now, each struct pid will refer to a different inode but the same
   struct pid will refer to the same inode if it's opened multiple
   times. In contrast to now where each struct pid refers to the same
   inode.

   The tiny pseudo filesystem is not visible anywhere in userspace
   exactly like e.g., pipefs and sockfs. There's no lookup, there's no
   complex inode operations, nothing. Dentries and inodes are always
   deleted when the last pidfd is closed.

   We allocate a new inode and dentry for each struct pid and we reuse
   that inode and dentry for all pidfds that refer to the same struct
   pid. The code is entirely optional and fairly small. If it's not
   selected we fallback to anonymous inodes. Heavily inspired by nsfs.

   The dentry and inode allocation mechanism is moved into generic
   infrastructure that is now shared between nsfs and pidfs. The
   path_from_stashed() helper must be provided with a stashing location,
   an inode number, a mount, and the private data that is supposed to be
   used and it will provide a path that can be passed to dentry_open().

   The helper will try retrieve an existing dentry from the provided
   stashing location. If a valid dentry is found it is reused. If not a
   new one is allocated and we try to stash it in the provided location.
   If this fails we retry until we either find an existing dentry or the
   newly allocated dentry could be stashed. Subsequent openers of the
   same namespace or task are then able to reuse it.

 - Currently it is only possible to get notified when a task has exited,
   i.e., become a zombie and userspace gets notified with EPOLLIN. We
   now also support waiting until the task has been reaped, notifying
   userspace with EPOLLHUP.

 - Ensure that ESRCH is reported for getfd if a task is exiting instead
   of the confusing EBADF.

 - Various smaller cleanups to pidfd functions.

* tag 'vfs-6.9.pidfd' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs: (23 commits)
  libfs: improve path_from_stashed()
  libfs: add stashed_dentry_prune()
  libfs: improve path_from_stashed() helper
  pidfs: convert to path_from_stashed() helper
  nsfs: convert to path_from_stashed() helper
  libfs: add path_from_stashed()
  pidfd: add pidfs
  pidfd: move struct pidfd_fops
  pidfd: allow to override signal scope in pidfd_send_signal()
  pidfd: change pidfd_send_signal() to respect PIDFD_THREAD
  signal: fill in si_code in prepare_kill_siginfo()
  selftests: add ESRCH tests for pidfd_getfd()
  pidfd: getfd should always report ESRCH if a task is exiting
  pidfd: clone: allow CLONE_THREAD | CLONE_PIDFD together
  pidfd: exit: kill the no longer used thread_group_exited()
  pidfd: change do_notify_pidfd() to use __wake_up(poll_to_key(EPOLLIN))
  pid: kill the obsolete PIDTYPE_PID code in transfer_pid()
  pidfd: kill the no longer needed do_notify_pidfd() in de_thread()
  pidfd_poll: report POLLHUP when pid_task() == NULL
  pidfd: implement PIDFD_THREAD flag for pidfd_open()
  ...
2024-03-11 10:21:06 -07:00
..
alsa kselftest/alsa - conf: Stringify the printed errno in sysfs_get() 2024-01-09 15:14:46 +01:00
amd-pstate selftests/amd-pstate: Added option to provide perf binary path 2023-10-16 13:06:58 -06:00
arm64 kselftest/arm64: Don't probe the current VL for unsupported vector types 2023-12-19 10:03:17 +00:00
bpf selftests/bpf: Fix up xdp bonding test wrt feature flags 2024-03-05 16:19:42 -08:00
breakpoints selftests/breakpoints: Fix format specifier in ksft_print_msg in step_after_suspend_test.c 2023-11-30 14:32:34 -07:00
cachestat selftests/cachestat: Fix print_cachestat format 2023-10-13 14:08:10 -06:00
capabilities selftests: capabilities: namespace create varies for root and normal user 2023-11-30 16:37:30 -07:00
cgroup Many singleton patches against the MM code. The patch series which 2024-01-09 11:18:47 -08:00
clone3 Many singleton patches against the MM code. The patch series which are 2023-11-02 19:38:47 -10:00
connector selftests: connector: Fix input argument error paths to skip 2023-07-31 20:11:42 -07:00
core selftests: core: include linux/close_range.h for CLOSE_RANGE_* macros 2024-02-07 21:20:34 -08:00
cpu-hotplug
cpufreq selftests/cpufreq: Don't enable generic lock debugging options 2023-06-12 16:39:11 -06:00
damon selftests/damon: add a test for update_schemes_tried_regions hang bug 2023-12-20 14:48:13 -08:00
dma
dmabuf-heaps selftests/dmabuf-heaps: add gitignore file 2023-10-05 14:22:59 -06:00
drivers selftests: bonding: set active slave to primary eth1 specifically 2024-02-19 09:11:35 +00:00
dt linux_kselftest-next-6.9-rc1 2024-03-11 09:25:33 -07:00
efivarfs selftests/efivarfs: create-read: fix a resource leak 2023-10-18 14:33:44 -06:00
exec selftests/exec: Convert execveat test to generate KTAP output 2023-10-05 14:50:03 -06:00
fchmodat2 selftests: link libasan statically for tests with -fsanitize=address 2023-09-19 13:21:32 -07:00
filelock selftests: add OFD lock tests 2023-08-24 10:41:47 -04:00
filesystems selftests/filesystems:fix build error in overlayfs 2024-01-22 15:33:37 +01:00
firmware selftests: firmware: remove duplicate unneeded defines 2023-10-06 17:33:52 -06:00
fpu
ftrace selftests/ftrace: Add test to exercize function tracer across cpu hotplug 2024-02-20 17:28:19 -07:00
futex selftests: fuxex: Report a unique test name per run of futex_requeue_pi 2024-02-19 15:00:51 -07:00
gpio gpio updates for v6.5 2023-06-29 10:11:10 -07:00
hid selftests/hid: wacom: fix confidence tests 2024-01-18 09:15:38 +01:00
ia64
intel_pstate
iommu selftests/iommu: fix the config fragment 2024-02-22 09:02:05 -04:00
ipc
ir
kcmp
kexec
kmod
kselftest selftests: ktap_helpers: Add a helper to finish the test 2024-02-20 15:53:20 -07:00
kvm KVM: selftests: Add a testcase to verify GUEST_MEMFD and READONLY are exclusive 2024-02-22 17:07:06 -08:00
landlock selftests/landlock: Fix capability for net_test 2024-02-02 10:32:09 +01:00
lib
livepatch linux_kselftest-next-6.9-rc1 2024-03-11 09:25:33 -07:00
lkdtm selftests/lkdtm: Disable CONFIG_UBSAN_TRAP in test config 2023-09-28 16:39:08 -07:00
locking
lsm selftests: remove the LSM_ID_IMA check in lsm/lsm_list_modules_test 2023-11-22 11:04:31 -05:00
media_tests selftests: media_tests: Add new subtest to video_device_test 2023-06-12 16:39:10 -06:00
membarrier
memfd selftests: improve vm.memfd_noexec sysctl tests 2023-08-21 13:38:00 -07:00
memory-hotplug
mincore selftests/mincore: fix skip condition for check_huge_pages test 2023-07-13 12:51:13 -06:00
mm selftests/mm: uffd-unit-test check if huge page size is 0 2024-02-20 14:20:48 -08:00
mount
mount_setattr
move_mount_set_group selftests/move_mount_set_group:Make tests build with old libc 2024-01-22 15:33:37 +01:00
mqueue selftests/mqueue: Set timeout to 180 seconds 2024-02-20 17:28:19 -07:00
nci
net selftests: mptcp: diag: avoid extra waiting 2024-03-04 13:05:15 +00:00
netfilter selftests: netfilter: add bridge conntrack + multicast test case 2024-02-29 00:22:48 +01:00
nolibc selftests/nolibc: disable coredump via setrlimit 2023-12-11 22:38:37 +01:00
nsfs
ntb
openat2 linux_kselftest-next-6.7-rc1 2023-11-01 17:08:10 -10:00
perf_events
pid_namespace
pidfd selftests: add ESRCH tests for pidfd_getfd() 2024-02-07 15:48:31 +01:00
power_supply selftests: Add test to verify power supply properties 2024-02-20 15:53:33 -07:00
powerpc selftests/powerpc: Fix fpu_signal failures 2024-03-01 22:15:30 +11:00
prctl selftests: prctl: Add prctl test for PR_GET_NAME 2023-11-30 16:30:05 -07:00
proc proc: test ProtectionKey in proc-empty-vm test 2023-11-01 12:46:59 -07:00
pstore
ptp ptp: add testptp mask test 2023-10-15 20:07:52 +01:00
ptrace
rcutorture rcutorture: Add mid-sized stall to TREE07 2023-11-23 11:58:18 +05:30
resctrl selftests/resctrl: Add non-contiguous CBMs CAT test 2024-02-23 15:19:25 -07:00
riscv RISC-V: selftests: cbo: Ensure asm operands match constraints 2024-01-17 17:46:55 -08:00
rlimits
rseq selftests/rseq: Do not skip !allowed_cpus for mm_cid 2024-01-22 11:40:36 -07:00
rtc
rust kselftest: Add basic test for probing the rust sample modules 2024-03-04 13:13:04 -07:00
safesetid
sched selftests: sched: Fix spelling mistake "hiearchy" -> "hierarchy" 2024-02-20 17:28:19 -07:00
seccomp kselftest/seccomp: Report each expectation we assert as a KTAP test 2024-01-30 08:55:42 -07:00
sgx selftests/sgx: Skip non X86_64 platform 2023-12-08 10:08:17 -08:00
sigaltstack selftests/sigaltstack: Fix wrong format specifier 2023-10-13 14:08:26 -06:00
size
sparc64
splice
static_keys selftests: static_keys: fix test name in messages 2023-10-05 14:28:59 -06:00
sync
syscall_user_dispatch
sysctl sysclt: Clarify the results of selftest run 2023-12-28 04:57:57 -08:00
tc-testing net/sched: Remove ipt action tests 2024-01-07 18:23:32 +00:00
tdx selftests/tdx: add gitignore file 2023-10-05 14:22:53 -06:00
thermal/intel selftests: thermal: intel: workload_hint: add missing gitignore 2024-02-20 16:30:55 -07:00
timens
timers selftests: timers: Convert nsleep-lat test to generate KTAP output 2023-10-05 15:00:14 -06:00
tmpfs
tpm2
tty selftests: tty: add selftest for tty timestamp updates 2023-06-15 13:45:42 +02:00
uevent selftests: uevent: add missing gitignore 2024-02-20 16:30:40 -07:00
user
user_events Tracing updates for v6.7: 2023-11-03 07:41:18 -10:00
vDSO kselftest/vDSO: Use ksft_print_msg() rather than printf in vdso_test_abi 2023-11-30 14:50:09 -07:00
watchdog
wireguard treewide: drop CONFIG_EMBEDDED 2023-08-21 13:46:25 -07:00
x86 selftests:x86: Fix Format String Warnings in lam.c 2023-11-30 14:32:41 -07:00
zram
.gitignore
Makefile kselftest: Add basic test for probing the rust sample modules 2024-03-04 13:13:04 -07:00
gen_kselftest_tar.sh
kselftest.h selftests:modify the incorrect print format 2023-10-18 14:33:44 -06:00
kselftest_deps.sh selftests: fix dependency checker script 2023-09-08 10:06:49 -06:00
kselftest_harness.h selftests/harness: Actually report SKIP for signal tests 2023-08-10 23:10:09 -07:00
kselftest_install.sh
kselftest_module.h
lib.mk selftests: lib.mk: Do not process TEST_GEN_MODS_DIR 2024-02-27 17:03:42 -07:00
run_kselftest.sh kselftest/runner.sh: add netns support 2023-12-23 00:26:32 +00:00