public inbox for linux-fsdevel@vger.kernel.org
 help / color / mirror / Atom feed
From: Christian Brauner <brauner@kernel.org>
To: Emanuele Rocca <emanuele.rocca@arm.com>
Cc: linux-kernel@vger.kernel.org, Jan Kara <jack@suse.cz>,
	 Alexander Viro <viro@zeniv.linux.org.uk>,
	linux-fsdevel@vger.kernel.org, Mark Brown <broonie@kernel.org>,
	 Jann Horn <jannh@google.com>, Oleg Nesterov <oleg@redhat.com>
Subject: Re: [PATCH v3] pidfds: add coredump_code field to pidfd_info
Date: Mon, 23 Mar 2026 12:57:22 +0100	[thread overview]
Message-ID: <20260323-hochsehen-kurort-862912a1d7b5@brauner> (raw)
In-Reply-To: <acBRj-DSCpqlKt6t@NH27D9T0LF>

On Sun, Mar 22, 2026 at 09:31:11PM +0100, Emanuele Rocca wrote:
> The struct pidfd_info currently exposes in a field called coredump_signal the
> signal number (si_signo) that triggered the dump (for example, 11 for SIGSEGV).
> However, it is also valuable to understand the reason why that signal was sent.
> This additional context is provided by the signal code (si_code), such as 2 for
> SEGV_ACCERR.
> 
> Add a new field to struct pidfd_info called coredump_code with the value of
> si_code for the benefit of sysadmins who pipe core dumps to user-space programs
> for later analysis. The following snippet illustrates a simplified C program
> that consumes coredump_signal and coredump_code, and then logs core dump
> signals and codes to a file:
> 
>     int pidfd = (int)atoi(argv[1]);
> 
>     struct pidfd_info info = {
>         .mask = PIDFD_INFO_EXIT | PIDFD_INFO_COREDUMP,
>     };
> 
>     if (ioctl(pidfd, PIDFD_GET_INFO, &info) == 0)
>         if (info.mask & PIDFD_INFO_COREDUMP)
>             fprintf(f, "PID=%d, si_signo: %d si_code: %d\n",
>                 info.pid, info.coredump_signal, info.coredump_code);
> 
> Assuming the program is installed under /usr/local/bin/core-logger, core dump
> processing can be enabled by setting /proc/sys/kernel/core_pattern to
> '|/usr/local/bin/dumpstuff %F'.
> 
> systemd-coredump(8) already uses pidfds to process core dumps, and it could be
> extended to include the values of coredump_code too.
> 
> Signed-off-by: Emanuele Rocca <emanuele.rocca@arm.com>
> ---
> Resending as a new thread, apologies for sending v2 as a follow-up to
> the kernel test robot instead!
> 
> V1 -> V2: Add coredump_pad to struct pidfd_info to ensure the struct has
> the same size on both 64 bit and 32 bit systems. The issue was spotted
> by the kernel test robot.
> v1: https://lore.kernel.org/lkml/ab29J6KsQm8Xg3LR@NH27D9T0LF/
> Link: https://lore.kernel.org/lkml/202603211842.JCwUVYTI-lkp@intel.com/
> 
> V2 -> V3: Sending as a new thread, same as v2 otherwise.
> v2: https://lore.kernel.org/lkml/ab68fUmCK4An1UH-@NH27D9T0LF/
> 
>  fs/pidfs.c                                    | 12 ++++---
>  include/uapi/linux/pidfd.h                    |  4 +++
>  .../coredump/coredump_socket_protocol_test.c  | 26 +++++++++++++++
>  .../selftests/coredump/coredump_socket_test.c | 32 +++++++++++++++++++
>  .../coredump/coredump_test_helpers.c          |  4 +--
>  tools/testing/selftests/pidfd/pidfd.h         |  5 +++
>  .../testing/selftests/pidfd/pidfd_info_test.c |  1 +
>  7 files changed, 78 insertions(+), 6 deletions(-)

Please split the kernel code from the selftest code into separate
commits. Thanks!

      parent reply	other threads:[~2026-03-23 11:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-22 20:31 [PATCH v3] pidfds: add coredump_code field to pidfd_info Emanuele Rocca
2026-03-23 11:47 ` Oleg Nesterov
2026-03-23 11:57 ` Christian Brauner [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260323-hochsehen-kurort-862912a1d7b5@brauner \
    --to=brauner@kernel.org \
    --cc=broonie@kernel.org \
    --cc=emanuele.rocca@arm.com \
    --cc=jack@suse.cz \
    --cc=jannh@google.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleg@redhat.com \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox