[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <156294329676.1745.2620297516210526183.stgit@buzz>
Date: Fri, 12 Jul 2019 17:54:56 +0300
From: Konstantin Khlebnikov <khlebnikov@...dex-team.ru>
To: Petr Mladek <pmladek@...e.com>, linux-kernel@...r.kernel.org,
Steven Rostedt <rostedt@...dmis.org>,
Sergey Senozhatsky <sergey.senozhatsky@...il.com>
Subject: [PATCH] kernel/printk: prevent deadlock at calling kmsg_dump from
NMI context
Function kmsg_dump could be invoked from NMI context intentionally or
accidentally because it is called at various oops/panic paths.
Kernel message dumpers are not ready to work in NMI context right now.
They could deadlock on lockbuf_lock or break internal structures.
Theoretically some dumpers could be fixed and marked as NMI-safe.
Right now it's safer to print warning once and give up.
Signed-off-by: Konstantin Khlebnikov <khlebnikov@...dex-team.ru>
---
kernel/printk/printk.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 1888f6a3b694..2b83820bdc57 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -3104,6 +3104,9 @@ void kmsg_dump(enum kmsg_dump_reason reason)
struct kmsg_dumper *dumper;
unsigned long flags;
+ if (WARN_ON_ONCE(in_nmi()))
+ return;
+
if ((reason > KMSG_DUMP_OOPS) && !always_kmsg_dump)
return;
Powered by blists - more mailing lists