diff options
author | Christian Brauner <brauner@kernel.org> | 2025-04-14 15:55:07 +0200 |
---|---|---|
committer | Christian Brauner <brauner@kernel.org> | 2025-05-02 14:28:47 +0200 |
commit | b5325b2a270fcaf7b2a9a0f23d422ca8a5a8bdea (patch) | |
tree | 19d4689861b1b941221e84cfea2a8ff23603a151 /net/unix/af_unix.c | |
parent | 95c5f43181fe9c1b5e5a4bd3281c857a5259991f (diff) |
coredump: hand a pidfd to the usermode coredump helper
Give userspace a way to instruct the kernel to install a pidfd into the
usermode helper process. This makes coredump handling a lot more
reliable for userspace. In parallel with this commit we already have
systemd adding support for this in [1].
We create a pidfs file for the coredumping process when we process the
corename pattern. When the usermode helper process is forked we then
install the pidfs file as file descriptor three into the usermode
helpers file descriptor table so it's available to the exec'd program.
Since usermode helpers are either children of the system_unbound_wq
workqueue or kthreadd we know that the file descriptor table is empty
and can thus always use three as the file descriptor number.
Note, that we'll install a pidfd for the thread-group leader even if a
subthread is calling do_coredump(). We know that task linkage hasn't
been removed due to delay_group_leader() and even if this @current isn't
the actual thread-group leader we know that the thread-group leader
cannot be reaped until @current has exited.
Link: https://github.com/systemd/systemd/pull/37125 [1]
Link: https://lore.kernel.org/20250414-work-coredump-v2-3-685bf231f828@kernel.org
Tested-by: Luca Boccassi <luca.boccassi@gmail.com>
Reviewed-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'net/unix/af_unix.c')
0 files changed, 0 insertions, 0 deletions