public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] printk: drop in_nmi check from printk_safe_flush_on_panic()
@ 2018-05-30  7:03 Sergey Senozhatsky
  2018-05-30  7:24 ` Petr Mladek
  2018-05-31 14:05 ` Petr Mladek
  0 siblings, 2 replies; 8+ messages in thread
From: Sergey Senozhatsky @ 2018-05-30  7:03 UTC (permalink / raw)
  To: Petr Mladek, Steven Rostedt
  Cc: Peter Zijlstra, linux-kernel, Sergey Senozhatsky,
	Sergey Senozhatsky

Drop the in_nmi() check from printk_safe_flush_on_panic()
and attempt to re-init (IOW unlock) locked logbuf spinlock
from panic CPU regardless of its context. Otherwise,
theoretically, we can deadlock on logbuf trying to flush
per-CPU buffers:
a) Panic CPU is running in non-NMI context
b) Panic CPU sends out shutdown IPI via reboot vector
c) Panic CPU fails to stop all remote CPUs
d) Panic CPU sends out shutdown IPI via NMI vector
   One of the CPUs that we bring down via NMI vector can hold
   logbuf spin lock (theoretically).

Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
---
 kernel/printk/printk_safe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/printk/printk_safe.c b/kernel/printk/printk_safe.c
index 3e3c2004bb23..baa80de5d8ec 100644
--- a/kernel/printk/printk_safe.c
+++ b/kernel/printk/printk_safe.c
@@ -278,7 +278,7 @@ void printk_safe_flush_on_panic(void)
 	 * Make sure that we could access the main ring buffer.
 	 * Do not risk a double release when more CPUs are up.
 	 */
-	if (in_nmi() && raw_spin_is_locked(&logbuf_lock)) {
+	if (raw_spin_is_locked(&logbuf_lock)) {
 		if (num_online_cpus() > 1)
 			return;
 
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-05-31 14:21 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-30  7:03 [PATCH] printk: drop in_nmi check from printk_safe_flush_on_panic() Sergey Senozhatsky
2018-05-30  7:24 ` Petr Mladek
2018-05-30  7:51   ` Sergey Senozhatsky
2018-05-30  8:48     ` Petr Mladek
2018-05-30  9:55       ` Sergey Senozhatsky
2018-05-30 10:00         ` Sergey Senozhatsky
2018-05-31 14:21           ` Petr Mladek
2018-05-31 14:05 ` Petr Mladek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox