coredump: add core_pattern specifier for si_code
Subsystems (2)
PATCH 1/1 coredump: add core_pattern specifier for si_code
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.
--- Documentation/admin-guide/sysctl/kernel.rst | 1 + fs/coredump.c | 5 +++++ 2 files changed, 6 insertions(+)
Documentation/admin-guide/sysctl/kernel.rst +1 -0
@@ -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)
fs/coredump.c +5 -0
@@ -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;
Signature · 1 line
2.47.3
Christian Brauner
maintainerQuoted 21 lines · Emanuele Rocca
The specifiers supported by
core_patterninclude the option to indicate the signal numbersi_signoby 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 codesi_code(eg: 2 forSEGV_ACCERR) provides this information.Adding the signal code to
core_patterncan 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 <[email protected]>--- Documentation/admin-guide/sysctl/kernel.rst | 1 + fs/coredump.c | 5 +++++ 2 files changed, 6 insertions(+)Documentation/admin-guide/sysctl/kernel.rst +0
-0
Documentation/admin-guide/sysctl/kernel.rst core_pattern · line 173
Quoted 4 lines
Documentation/admin-guide/sysctl/kernel.rst +1
-0@@ -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
Request %F which installs pidfd for the coredumping process into the coredump helper then use the pidfd info ioctl in you binary with PIDFD_INFO_EXIT | PIDFD_INFO_COREDUMP and you can retrieve the exit status including the signal that was sent to the process.
Hi Christian,
Quoted 4 lines · Christian Brauner
Request %F which installs pidfd for the coredumping process into the coredump helper then use the pidfd info ioctl in you binary with
PIDFD_INFO_EXIT|PIDFD_INFO_COREDUMPand you can retrieve the exit status including the signal that was sent to the process.
Correct me if I'm wrong, but PIDFD_INFO_COREDUMP seems to be setting coredump_signal, which is siginfo->si_signo? That information is already available by using the %s core_pattern specifier anyways.
What I am looking for is si_code instead. Perhaps a field could be added to struct pidfs_attr and set in fs/pidfs.c similarly to what is currently done for si_signo?
Christian Brauner
maintainerQuoted 8 lines · Emanuele Rocca
Hi Christian,
Quoted 4 lines · Christian Brauner
Request %F which installs pidfd for the coredumping process into the coredump helper then use the pidfd info ioctl in you binary with
PIDFD_INFO_EXIT|PIDFD_INFO_COREDUMPand you can retrieve the exit status including the signal that was sent to the process.
Quoted 7 lines
Correct me if I'm wrong, but
PIDFD_INFO_COREDUMPseems to be settingcoredump_signal, which issiginfo->si_signo? That information is already available by using the %score_patternspecifier anyways.What I am looking for is
si_codeinstead. Perhaps a field could be added to structpidfs_attrand set infs/pidfs.csimilarly to what is currently done forsi_signo?
I see. I don't have a problem with doing that. Let's rope in @Jann and @Oleg to see whether they have any info-leak/security concerns around this.