[PATCH] siganl: ignore other signals when doing coredump

chunlei.wang Chunlei.wang at mediatek.com
Thu Jul 23 02:52:23 EDT 2020


do_coredump flow is interrupted by SIGKILL,
causing the coredump to be truncated.

Signed-off-by: Chunlei Wang <chunlei.wang at mediatek.com>
---
 arch/Kconfig    | 12 ++++++++++++
 kernel/signal.c |  8 ++++++++
 2 files changed, 20 insertions(+)

diff --git a/arch/Kconfig b/arch/Kconfig
index 8cc35dc556c7..559eac47093e 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -834,6 +834,18 @@ config OLD_SIGACTION
 config COMPAT_OLD_SIGACTION
 	bool
 
+config IGNORE_ANY_SIGNALS
+	tristate "ignore any signals when coredump is doing"
+	default n
+	help
+	  The sigkill is very special. If a process receives a sigkill, it
will
+	  immediately respond to the sigkill. When a process is abnormal and
+	  collecting coredump, the do_coredump flow will be interrupted by
+	  SIGKILL, causing the coredump to be truncated. This truncated
coredump
+	  is incomplete, and also gdb can't load.
+	  Maybe we can ignore any signlas when process is collecting coredump.
+	  This config can decide whether to ignore any signals.
+
 config COMPAT_32BIT_TIME
 	bool "Provide system calls for 32-bit time_t"
 	default !64BIT || COMPAT
diff --git a/kernel/signal.c b/kernel/signal.c
index 5ca48cc5da76..ccae3c84eb6d 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -903,6 +903,14 @@ static bool prepare_signal(int sig, struct
task_struct *p, bool force)
 	sigset_t flush;
 
 	if (signal->flags & (SIGNAL_GROUP_EXIT | SIGNAL_GROUP_COREDUMP)) {
+
+#if defined CONFIG_IGNORE_ANY_SIGNALS
+		if (signal->flags & SIGNAL_GROUP_COREDUMP) {
+			pr_debug("[%d:%s] skip sig %d due to coredump is doing\n",
+					p->pid, p->comm, sig);
+			return false;
+		}
+#endif
 		if (!(signal->flags & SIGNAL_GROUP_EXIT))
 			return sig == SIGKILL;
 		/*
-- 
2.18.0



More information about the Linux-mediatek mailing list