Skip to content

Commit b0b88e0

Browse files
vwaxakpm00
authored andcommitted
signal: print comm and exe name on fatal signals
Make the print-fatal-signals message more useful by printing the comm and the exe name for the process which received the fatal signal: Before: potentially unexpected fatal signal 4 potentially unexpected fatal signal 11 After: buggy-program: pool: potentially unexpected fatal signal 4 some-daemon: gdbus: potentially unexpected fatal signal 11 comm used to be present but was removed in commit 681a90f ("arc, print-fatal-signals: reduce duplicated information") because it's also included as part of the later stack trace. Having the comm as part of the main "unexpected fatal..." print is rather useful though when analysing logs, and the exe name is also valuable as shown in the examples above where the comm ends up having some generic name like "pool". [[email protected]: don't include linux/file.h twice] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Vincent Whitchurch <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Tejun Heo <[email protected]> Cc: Vineet Gupta <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 9702a04 commit b0b88e0

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

kernel/signal.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <linux/sched/cputime.h>
2323
#include <linux/file.h>
2424
#include <linux/fs.h>
25+
#include <linux/mm.h>
2526
#include <linux/proc_fs.h>
2627
#include <linux/tty.h>
2728
#include <linux/binfmts.h>
@@ -1260,7 +1261,17 @@ int send_signal_locked(int sig, struct kernel_siginfo *info,
12601261
static void print_fatal_signal(int signr)
12611262
{
12621263
struct pt_regs *regs = task_pt_regs(current);
1263-
pr_info("potentially unexpected fatal signal %d.\n", signr);
1264+
struct file *exe_file;
1265+
1266+
exe_file = get_task_exe_file(current);
1267+
if (exe_file) {
1268+
pr_info("%pD: %s: potentially unexpected fatal signal %d.\n",
1269+
exe_file, current->comm, signr);
1270+
fput(exe_file);
1271+
} else {
1272+
pr_info("%s: potentially unexpected fatal signal %d.\n",
1273+
current->comm, signr);
1274+
}
12641275

12651276
#if defined(__i386__) && !defined(__arch_um__)
12661277
pr_info("code at %08lx: ", regs->ip);

0 commit comments

Comments
 (0)