]> www.infradead.org Git - users/jedix/linux-maple.git/commit
coredump: hand a pidfd to the usermode coredump helper
authorChristian Brauner <brauner@kernel.org>
Mon, 14 Apr 2025 13:55:07 +0000 (15:55 +0200)
committerChristian Brauner <brauner@kernel.org>
Fri, 2 May 2025 12:28:47 +0000 (14:28 +0200)
commitb5325b2a270fcaf7b2a9a0f23d422ca8a5a8bdea
tree19d4689861b1b941221e84cfea2a8ff23603a151
parent95c5f43181fe9c1b5e5a4bd3281c857a5259991f
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
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>
fs/coredump.c
include/linux/coredump.h