[RESEND PATCH net-next 0/6] allow reaped pidfds receive in SCM_PIDFD

From: Alexander Mikhalitsyn
Date: Sun Jun 29 2025 - 17:45:14 EST


This is a logical continuation of a story from [1], where Christian
extented SO_PEERPIDFD to allow getting pidfds for a reaped tasks.

Git tree:
https://github.com/mihalicyn/linux/commits/scm_pidfd_stale

Series based on https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git/log/?h=vfs-6.17.pidfs

It does not use pidfs_get_pid()/pidfs_put_pid() API as these were removed in a scope of [2].
I've checked that net-next branch currently (still) has these obsolete functions, but it
will eventually include changes from [2], so it's not a big problem.

Link: https://lore.kernel.org/all/20250425-work-pidfs-net-v2-0-450a19461e75@xxxxxxxxxx/ [1]
Link: https://lore.kernel.org/all/20250618-work-pidfs-persistent-v2-0-98f3456fd552@xxxxxxxxxx/ [2]

Cc: linux-kernel@xxxxxxxxxxxxxxx
Cc: netdev@xxxxxxxxxxxxxxx
Cc: "David S. Miller" <davem@xxxxxxxxxxxxx>
Cc: Eric Dumazet <edumazet@xxxxxxxxxx>
Cc: Jakub Kicinski <kuba@xxxxxxxxxx>
Cc: Paolo Abeni <pabeni@xxxxxxxxxx>
Cc: Willem de Bruijn <willemb@xxxxxxxxxx>
Cc: Leon Romanovsky <leon@xxxxxxxxxx>
Cc: Arnd Bergmann <arnd@xxxxxxxx>
Cc: Christian Brauner <brauner@xxxxxxxxxx>
Cc: Kuniyuki Iwashima <kuniyu@xxxxxxxxxx>
Cc: Lennart Poettering <mzxreary@xxxxxxxxxxx>
Cc: Luca Boccassi <bluca@xxxxxxxxxx>
Cc: David Rheinsberg <david@xxxxxxxxxxxx>

Alexander Mikhalitsyn (6):
af_unix: rework unix_maybe_add_creds() to allow sleep
af_unix: introduce unix_skb_to_scm helper
af_unix: introduce and use __scm_replace_pid() helper
af_unix: stash pidfs dentry when needed
af_unix: enable handing out pidfds for reaped tasks in SCM_PIDFD
selftests: net: extend SCM_PIDFD test to cover stale pidfds

include/net/scm.h | 46 +++-
net/core/scm.c | 13 +-
net/unix/af_unix.c | 76 ++++--
.../testing/selftests/net/af_unix/scm_pidfd.c | 217 ++++++++++++++----
4 files changed, 285 insertions(+), 67 deletions(-)

--
2.43.0