]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.14.60/printk-drop-in_nmi-check-from-printk_safe_flush_on_panic.patch
Remove duplicated commits
[thirdparty/kernel/stable-queue.git] / releases / 4.14.60 / printk-drop-in_nmi-check-from-printk_safe_flush_on_panic.patch
1 From foo@baz Sat Jul 28 10:25:26 CEST 2018
2 From: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
3 Date: Wed, 30 May 2018 16:03:50 +0900
4 Subject: printk: drop in_nmi check from printk_safe_flush_on_panic()
5
6 From: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
7
8 [ Upstream commit 554755be08fba31c74f66b82a485e5513205af84 ]
9
10 Drop the in_nmi() check from printk_safe_flush_on_panic()
11 and attempt to re-init (IOW unlock) locked logbuf spinlock
12 from panic CPU regardless of its context.
13
14 Otherwise, theoretically, we can deadlock on logbuf trying to flush
15 per-CPU buffers:
16
17 a) Panic CPU is running in non-NMI context
18 b) Panic CPU sends out shutdown IPI via reboot vector
19 c) Panic CPU fails to stop all remote CPUs
20 d) Panic CPU sends out shutdown IPI via NMI vector
21 One of the CPUs that we bring down via NMI vector can hold
22 logbuf spin lock (theoretically).
23
24 Link: http://lkml.kernel.org/r/20180530070350.10131-1-sergey.senozhatsky@gmail.com
25 To: Steven Rostedt <rostedt@goodmis.org>
26 Cc: Peter Zijlstra <peterz@infradead.org>
27 Cc: linux-kernel@vger.kernel.org
28 Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
29 Signed-off-by: Petr Mladek <pmladek@suse.com>
30 Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
31 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
32 ---
33 kernel/printk/printk_safe.c | 2 +-
34 1 file changed, 1 insertion(+), 1 deletion(-)
35
36 --- a/kernel/printk/printk_safe.c
37 +++ b/kernel/printk/printk_safe.c
38 @@ -284,7 +284,7 @@ void printk_safe_flush_on_panic(void)
39 * Make sure that we could access the main ring buffer.
40 * Do not risk a double release when more CPUs are up.
41 */
42 - if (in_nmi() && raw_spin_is_locked(&logbuf_lock)) {
43 + if (raw_spin_is_locked(&logbuf_lock)) {
44 if (num_online_cpus() > 1)
45 return;
46