arch/alpha/include/uapi/asm/socket.h | 4 + arch/mips/include/uapi/asm/socket.h | 4 + arch/parisc/include/uapi/asm/socket.h | 4 + arch/sparc/include/uapi/asm/socket.h | 4 + fs/coredump.c | 22 +- fs/pidfs.c | 27 +- include/linux/coredump.h | 4 +- include/linux/pid.h | 53 +++ include/linux/pid_types.h | 8 + include/linux/pidfs.h | 5 + include/linux/sched/signal.h | 18 + include/net/scm.h | 7 +- include/net/sock.h | 14 +- include/trace/events/landlock.h | 2 +- include/uapi/asm-generic/socket.h | 4 + net/bluetooth/af_bluetooth.c | 6 +- net/bluetooth/hci_sock.c | 8 +- net/bluetooth/l2cap_sock.c | 2 +- net/core/scm.c | 36 +- net/core/sock.c | 120 ++++--- net/unix/af_unix.c | 67 ++-- net/unix/af_unix.h | 3 +- tools/lib/python/kdoc/xforms_lists.py | 1 + .../selftests/coredump/coredump_socket_test.c | 175 ++++++++++ tools/testing/selftests/coredump/coredump_test.h | 2 + .../selftests/coredump/coredump_test_helpers.c | 49 +++ tools/testing/selftests/net/af_unix/Makefile | 2 + tools/testing/selftests/net/af_unix/scm_pidfd.c | 366 +++++++++++++++++++++ 28 files changed, 907 insertions(+), 110 deletions(-)
SO_PASSPIDFD/SCM_PIDFD and SO_PEERPIDFD allow to retrieve a pidfd for
the thread-group leader. The coredump server using the coredump socket
cannot get a handle on the task that took the signal and is writing the
coredump easily. Workloads interested in per-thread authentification
have similar problems.
Add SO_PASSPIDFD_THREAD and SO_PEERPIDFD_THREAD. We record the sending
and the connecting thread in addition to the thread-group leader.
SO_PASSPIDFD_THREAD functions like SO_PASSPIDFD but instead of an
SCM_PIDFD message for the thread-group leader, SCM_PIDFD sends a pidfd
for the specific thread. SO_PASSPIDFD_THREAD is mutually exclusive with
SO_PASSPIDFD. The last one set takes precedence and disables the other
one. Both SO_PASSCRED and SO_PASSPIDFD receivers see one writer per
process as before.
SO_PEERPIDFD_THREAD allows to retrieve a pidfd for the specific thread
that called connect(), listen(), or socketpair().
pidfs_coredump() now also stamps the dumping thread's struct pid so a
pidfd for that thread reports the coredump like the pidfd of the
thread-group leader does.
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
---
Changes in v2:
- Fix a few documentation issues.
- Link to v1: https://patch.msgid.link/20260831-work-unix-passpidfd-v1-0-70cbfda0c7ba@kernel.org
---
Christian Brauner (10):
pid: add helpers to operate on a struct pid array
af_unix: record the pid of the sending thread
net: add SO_PASSPIDFD_THREAD to get a thread-specific SCM_PIDFD
selftests/net: SO_PASSPIDFD_THREAD
net: turn sk_peer_pid into an array indexed by pid type
af_unix: record the pid of the connecting thread
net: add SO_PEERPIDFD_THREAD to get a thread-specific pidfd
selftests/net: SO_PEERPIDFD_THREAD
pidfs: record the coredump on the dumping thread's pid too
selftests/coredump: check the dumping thread's pidfd
arch/alpha/include/uapi/asm/socket.h | 4 +
arch/mips/include/uapi/asm/socket.h | 4 +
arch/parisc/include/uapi/asm/socket.h | 4 +
arch/sparc/include/uapi/asm/socket.h | 4 +
fs/coredump.c | 22 +-
fs/pidfs.c | 27 +-
include/linux/coredump.h | 4 +-
include/linux/pid.h | 53 +++
include/linux/pid_types.h | 8 +
include/linux/pidfs.h | 5 +
include/linux/sched/signal.h | 18 +
include/net/scm.h | 7 +-
include/net/sock.h | 14 +-
include/trace/events/landlock.h | 2 +-
include/uapi/asm-generic/socket.h | 4 +
net/bluetooth/af_bluetooth.c | 6 +-
net/bluetooth/hci_sock.c | 8 +-
net/bluetooth/l2cap_sock.c | 2 +-
net/core/scm.c | 36 +-
net/core/sock.c | 120 ++++---
net/unix/af_unix.c | 67 ++--
net/unix/af_unix.h | 3 +-
tools/lib/python/kdoc/xforms_lists.py | 1 +
.../selftests/coredump/coredump_socket_test.c | 175 ++++++++++
tools/testing/selftests/coredump/coredump_test.h | 2 +
.../selftests/coredump/coredump_test_helpers.c | 49 +++
tools/testing/selftests/net/af_unix/Makefile | 2 +
tools/testing/selftests/net/af_unix/scm_pidfd.c | 366 +++++++++++++++++++++
28 files changed, 907 insertions(+), 110 deletions(-)
---
base-commit: cee9395acd8043be0644b25c34bfa86623f2b935
change-id: 20260825-work-unix-passpidfd-086a1ec09e8a
On Wed, Sep 9, 2026 at 3:43 AM Christian Brauner <brauner@kernel.org> wrote: > > SO_PASSPIDFD/SCM_PIDFD and SO_PEERPIDFD allow to retrieve a pidfd for > the thread-group leader. The coredump server using the coredump socket > cannot get a handle on the task that took the signal and is writing the > coredump easily. Workloads interested in per-thread authentification > have similar problems. > > Add SO_PASSPIDFD_THREAD and SO_PEERPIDFD_THREAD. We record the sending > and the connecting thread in addition to the thread-group leader. > > SO_PASSPIDFD_THREAD functions like SO_PASSPIDFD but instead of an > SCM_PIDFD message for the thread-group leader, SCM_PIDFD sends a pidfd > for the specific thread. SO_PASSPIDFD_THREAD is mutually exclusive with > SO_PASSPIDFD. The last one set takes precedence and disables the other > one. Both SO_PASSCRED and SO_PASSPIDFD receivers see one writer per > process as before. > > SO_PEERPIDFD_THREAD allows to retrieve a pidfd for the specific thread > that called connect(), listen(), or socketpair(). > > pidfs_coredump() now also stamps the dumping thread's struct pid so a > pidfd for that thread reports the coredump like the pidfd of the > thread-group leader does. systemd-coredump currently uses SO_PEERPIDFD, so SO_PEERPIDFD_THREAD makes sense to me, but is there real need/use-case to fetch each thread's pidfd per sendmsg() via cmsg ? > > Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org> > --- > Changes in v2: > - Fix a few documentation issues. > - Link to v1: https://patch.msgid.link/20260831-work-unix-passpidfd-v1-0-70cbfda0c7ba@kernel.org > > --- > Christian Brauner (10): > pid: add helpers to operate on a struct pid array > af_unix: record the pid of the sending thread > net: add SO_PASSPIDFD_THREAD to get a thread-specific SCM_PIDFD > selftests/net: SO_PASSPIDFD_THREAD > net: turn sk_peer_pid into an array indexed by pid type > af_unix: record the pid of the connecting thread > net: add SO_PEERPIDFD_THREAD to get a thread-specific pidfd > selftests/net: SO_PEERPIDFD_THREAD > pidfs: record the coredump on the dumping thread's pid too > selftests/coredump: check the dumping thread's pidfd > > arch/alpha/include/uapi/asm/socket.h | 4 + > arch/mips/include/uapi/asm/socket.h | 4 + > arch/parisc/include/uapi/asm/socket.h | 4 + > arch/sparc/include/uapi/asm/socket.h | 4 + > fs/coredump.c | 22 +- > fs/pidfs.c | 27 +- > include/linux/coredump.h | 4 +- > include/linux/pid.h | 53 +++ > include/linux/pid_types.h | 8 + > include/linux/pidfs.h | 5 + > include/linux/sched/signal.h | 18 + > include/net/scm.h | 7 +- > include/net/sock.h | 14 +- > include/trace/events/landlock.h | 2 +- > include/uapi/asm-generic/socket.h | 4 + > net/bluetooth/af_bluetooth.c | 6 +- > net/bluetooth/hci_sock.c | 8 +- > net/bluetooth/l2cap_sock.c | 2 +- > net/core/scm.c | 36 +- > net/core/sock.c | 120 ++++--- > net/unix/af_unix.c | 67 ++-- > net/unix/af_unix.h | 3 +- > tools/lib/python/kdoc/xforms_lists.py | 1 + > .../selftests/coredump/coredump_socket_test.c | 175 ++++++++++ > tools/testing/selftests/coredump/coredump_test.h | 2 + > .../selftests/coredump/coredump_test_helpers.c | 49 +++ > tools/testing/selftests/net/af_unix/Makefile | 2 + > tools/testing/selftests/net/af_unix/scm_pidfd.c | 366 +++++++++++++++++++++ > 28 files changed, 907 insertions(+), 110 deletions(-) > --- > base-commit: cee9395acd8043be0644b25c34bfa86623f2b935 > change-id: 20260825-work-unix-passpidfd-086a1ec09e8a >
On 2026-09-09 23:33 -0700, Kuniyuki Iwashima wrote: > On Wed, Sep 9, 2026 at 3:43 AM Christian Brauner <brauner@kernel.org> wrote: > > > > SO_PASSPIDFD/SCM_PIDFD and SO_PEERPIDFD allow to retrieve a pidfd for > > the thread-group leader. The coredump server using the coredump socket > > cannot get a handle on the task that took the signal and is writing the > > coredump easily. Workloads interested in per-thread authentification > > have similar problems. > > > > Add SO_PASSPIDFD_THREAD and SO_PEERPIDFD_THREAD. We record the sending > > and the connecting thread in addition to the thread-group leader. > > > > SO_PASSPIDFD_THREAD functions like SO_PASSPIDFD but instead of an > > SCM_PIDFD message for the thread-group leader, SCM_PIDFD sends a pidfd > > for the specific thread. SO_PASSPIDFD_THREAD is mutually exclusive with > > SO_PASSPIDFD. The last one set takes precedence and disables the other > > one. Both SO_PASSCRED and SO_PASSPIDFD receivers see one writer per > > process as before. > > > > SO_PEERPIDFD_THREAD allows to retrieve a pidfd for the specific thread > > that called connect(), listen(), or socketpair(). > > > > pidfs_coredump() now also stamps the dumping thread's struct pid so a > > pidfd for that thread reports the coredump like the pidfd of the > > thread-group leader does. > > systemd-coredump currently uses SO_PEERPIDFD, so And dbus-broker and polkit and etc pp. > SO_PEERPIDFD_THREAD makes sense to me, but is there > real need/use-case to fetch each thread's pidfd per sendmsg() > via cmsg ? I want to be able to authenticate individual threads in a thread-group on a per message basis in an authentication framework. Thanks for the review!
On Wed, 09 Sep 2026 12:42:59 +0200, Christian Brauner wrote:
> SO_PASSPIDFD/SCM_PIDFD and SO_PEERPIDFD allow to retrieve a pidfd for
> the thread-group leader. The coredump server using the coredump socket
> cannot get a handle on the task that took the signal and is writing the
> coredump easily. Workloads interested in per-thread authentification
> have similar problems.
>
> Add SO_PASSPIDFD_THREAD and SO_PEERPIDFD_THREAD. We record the sending
> and the connecting thread in addition to the thread-group leader.
>
> [...]
@Jakub, shared branch in vfs-7.4.shared.net-next.pidfd. I'm open to rebasing if
you have need for that on your end during the cycle.
---
Applied to the vfs-7.4.shared.net-next.pidfd branch of the vfs/vfs.git tree.
Patches in the vfs-7.4.shared.net-next.pidfd branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs-7.4.shared.net-next.pidfd
[01/10] pid: add helpers to operate on a struct pid array
https://git.kernel.org/vfs/vfs/c/b674dcb18f1d
[02/10] af_unix: record the pid of the sending thread
https://git.kernel.org/vfs/vfs/c/a8575fe8b94e
[03/10] net: add SO_PASSPIDFD_THREAD to get a thread-specific SCM_PIDFD
https://git.kernel.org/vfs/vfs/c/78dc8469581d
[04/10] selftests/net: SO_PASSPIDFD_THREAD
https://git.kernel.org/vfs/vfs/c/7810049c5675
[05/10] net: turn sk_peer_pid into an array indexed by pid type
https://git.kernel.org/vfs/vfs/c/0149a6ceaf8f
[06/10] af_unix: record the pid of the connecting thread
https://git.kernel.org/vfs/vfs/c/4dd362b00be5
[07/10] net: add SO_PEERPIDFD_THREAD to get a thread-specific pidfd
https://git.kernel.org/vfs/vfs/c/41972f2e5ab0
[08/10] selftests/net: SO_PEERPIDFD_THREAD
https://git.kernel.org/vfs/vfs/c/6e8bef9686e4
[09/10] pidfs: record the coredump on the dumping thread's pid too
https://git.kernel.org/vfs/vfs/c/52671ec3712c
[10/10] selftests/coredump: check the dumping thread's pidfd
https://git.kernel.org/vfs/vfs/c/b956027e73be
On Wed, 9 Sep 2026 14:40:25 +0200 Christian Brauner wrote: > @Jakub, shared branch in vfs-7.4.shared.net-next.pidfd. I'm open to rebasing if > you have need for that on your end during the cycle. SG, thanks! Once we pull the hashes need to stay stable, we have a lot of subordinate trees and too much code for feature branches. Let's give it a couple of days, let AI and Kuniyuki review, and take it from there.
Am Mi., 9. Sept. 2026 um 12:43 Uhr schrieb Christian Brauner <brauner@kernel.org>: > > SO_PASSPIDFD/SCM_PIDFD and SO_PEERPIDFD allow to retrieve a pidfd for > the thread-group leader. The coredump server using the coredump socket > cannot get a handle on the task that took the signal and is writing the > coredump easily. Workloads interested in per-thread authentification > have similar problems. > > Add SO_PASSPIDFD_THREAD and SO_PEERPIDFD_THREAD. We record the sending > and the connecting thread in addition to the thread-group leader. > > SO_PASSPIDFD_THREAD functions like SO_PASSPIDFD but instead of an > SCM_PIDFD message for the thread-group leader, SCM_PIDFD sends a pidfd > for the specific thread. SO_PASSPIDFD_THREAD is mutually exclusive with > SO_PASSPIDFD. The last one set takes precedence and disables the other > one. Both SO_PASSCRED and SO_PASSPIDFD receivers see one writer per > process as before. > > SO_PEERPIDFD_THREAD allows to retrieve a pidfd for the specific thread > that called connect(), listen(), or socketpair(). > > pidfs_coredump() now also stamps the dumping thread's struct pid so a > pidfd for that thread reports the coredump like the pidfd of the > thread-group leader does. > > Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org> Reviewed-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@futurfusion.io> > --- > Changes in v2: > - Fix a few documentation issues. > - Link to v1: https://patch.msgid.link/20260831-work-unix-passpidfd-v1-0-70cbfda0c7ba@kernel.org > > --- > Christian Brauner (10): > pid: add helpers to operate on a struct pid array > af_unix: record the pid of the sending thread > net: add SO_PASSPIDFD_THREAD to get a thread-specific SCM_PIDFD > selftests/net: SO_PASSPIDFD_THREAD > net: turn sk_peer_pid into an array indexed by pid type > af_unix: record the pid of the connecting thread > net: add SO_PEERPIDFD_THREAD to get a thread-specific pidfd > selftests/net: SO_PEERPIDFD_THREAD > pidfs: record the coredump on the dumping thread's pid too > selftests/coredump: check the dumping thread's pidfd > > arch/alpha/include/uapi/asm/socket.h | 4 + > arch/mips/include/uapi/asm/socket.h | 4 + > arch/parisc/include/uapi/asm/socket.h | 4 + > arch/sparc/include/uapi/asm/socket.h | 4 + > fs/coredump.c | 22 +- > fs/pidfs.c | 27 +- > include/linux/coredump.h | 4 +- > include/linux/pid.h | 53 +++ > include/linux/pid_types.h | 8 + > include/linux/pidfs.h | 5 + > include/linux/sched/signal.h | 18 + > include/net/scm.h | 7 +- > include/net/sock.h | 14 +- > include/trace/events/landlock.h | 2 +- > include/uapi/asm-generic/socket.h | 4 + > net/bluetooth/af_bluetooth.c | 6 +- > net/bluetooth/hci_sock.c | 8 +- > net/bluetooth/l2cap_sock.c | 2 +- > net/core/scm.c | 36 +- > net/core/sock.c | 120 ++++--- > net/unix/af_unix.c | 67 ++-- > net/unix/af_unix.h | 3 +- > tools/lib/python/kdoc/xforms_lists.py | 1 + > .../selftests/coredump/coredump_socket_test.c | 175 ++++++++++ > tools/testing/selftests/coredump/coredump_test.h | 2 + > .../selftests/coredump/coredump_test_helpers.c | 49 +++ > tools/testing/selftests/net/af_unix/Makefile | 2 + > tools/testing/selftests/net/af_unix/scm_pidfd.c | 366 +++++++++++++++++++++ > 28 files changed, 907 insertions(+), 110 deletions(-) > --- > base-commit: cee9395acd8043be0644b25c34bfa86623f2b935 > change-id: 20260825-work-unix-passpidfd-086a1ec09e8a >
© 2016 - 2026 Red Hat, Inc.