All of lore.kernel.org
 help / color / mirror / Atom feed
From: Emanuele Rocca <emanuele.rocca@arm.com>
To: linux-kernel@vger.kernel.org
Cc: Alexander Viro <viro@zeniv.linux.org.uk>,
	Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
	linux-fsdevel@vger.kernel.org, Mark Brown <broonie@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH] coredump: add core_pattern specifier for si_code
Date: Tue, 17 Mar 2026 16:00:06 +0100	[thread overview]
Message-ID: <ablsdmLsMKm0z5wt@NH27D9T0LF> (raw)

The specifiers supported by core_pattern include the option to indicate the
signal number si_signo by using %s. Other than identifying which signal
generated a core dump (eg: 11 for SIGSEGV), it is useful to know the reason why
a certain signal was sent. The signal code si_code (eg: 2 for SEGV_ACCERR)
provides this information.

Adding the signal code to core_pattern can benefit in particular sysadmins who
pipe core dumps to user-space programs for later analysis. systemd-coredump(8)
is a notable example of such programs.

Signed-off-by: Emanuele Rocca <emanuele.rocca@arm.com>
---
 Documentation/admin-guide/sysctl/kernel.rst | 1 +
 fs/coredump.c                               | 5 +++++
 2 files changed, 6 insertions(+)

diff --git a/Documentation/admin-guide/sysctl/kernel.rst b/Documentation/admin-guide/sysctl/kernel.rst
index 9aed74e65cf4..20177bd94514 100644
--- a/Documentation/admin-guide/sysctl/kernel.rst
+++ b/Documentation/admin-guide/sysctl/kernel.rst
@@ -170,6 +170,7 @@ core_pattern
 	%d		dump mode, matches ``PR_SET_DUMPABLE`` and
 			``/proc/sys/fs/suid_dumpable``
 	%s		signal number
+	%n		signal code
 	%t		UNIX time of dump
 	%h		hostname
 	%e		executable filename (may be shortened, could be changed by prctl etc)
diff --git a/fs/coredump.c b/fs/coredump.c
index 29df8aa19e2e..e78a889fe34c 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -400,6 +400,11 @@ static bool coredump_parse(struct core_name *cn, struct coredump_params *cprm,
 				err = cn_printf(cn, "%d",
 						cprm->siginfo->si_signo);
 				break;
+			/* code of the signal that caused the coredump */
+			case 'n':
+				err = cn_printf(cn, "%d",
+						cprm->siginfo->si_code);
+				break;
 			/* UNIX time of coredump */
 			case 't': {
 				time64_t time;
-- 
2.47.3


             reply	other threads:[~2026-03-17 15:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-17 15:00 Emanuele Rocca [this message]
2026-03-18  9:45 ` [PATCH] coredump: add core_pattern specifier for si_code Christian Brauner
2026-03-18 13:17   ` Emanuele Rocca
2026-03-19 10:31     ` Christian Brauner

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=ablsdmLsMKm0z5wt@NH27D9T0LF \
    --to=emanuele.rocca@arm.com \
    --cc=akpm@linux-foundation.org \
    --cc=brauner@kernel.org \
    --cc=broonie@kernel.org \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.