[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240528101957.7277-1-TonyWWang-oc@zhaoxin.com>
Date: Tue, 28 May 2024 18:19:57 +0800
From: Tony W Wang-oc <TonyWWang-oc@...oxin.com>
To: <tglx@...utronix.de>, <mingo@...hat.com>, <bp@...en8.de>, <hpa@...or.com>,
<x86@...nel.org>, <jpoimboe@...nel.org>, <vlovejoy@...hat.com>,
<gregkh@...uxfoundation.org>, <oleg@...hat.com>, <TonyWWang-oc@...oxin.com>,
<linux-kernel@...r.kernel.org>
CC: <CobeChen@...oxin.com>, <TimGuo@...oxin.com>, <LeoLiu-oc@...oxin.com>
Subject: [PATCH] linux-4.19.y/printk: Avoid logbuf_lock deadlock in oops_end()
A CPU executing vprintk_emit might be interrupted by #PF exception,
this may leads to logbuf_lock deadlock:
CPU x: CPU x:
---- ----
vprintk_emit()
logbuf_lock_irqsave()
printk_safe_enter_irqsave()
A: raw_spin_lock(&logbuf_lock)
vprintk_store() #PF
do_page_fault
...
oops_end
bust_spinlocks(0)
console_unlock()
...
printk_safe_enter_irqsave()
B: raw_spin_lock(&logbuf_lock)
logbuf_lock is taken at A and the deadlock happends at B.
Pass 1 to bust_spinlocks() in the oops_end() to avoid this deadlock.
Signed-off-by: Tony W Wang-oc <TonyWWang-oc@...oxin.com>
---
arch/x86/kernel/dumpstack.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
index 7e698c45760c..b4c145ee9536 100644
--- a/arch/x86/kernel/dumpstack.c
+++ b/arch/x86/kernel/dumpstack.c
@@ -336,7 +336,7 @@ void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
if (regs && kexec_should_crash(current))
crash_kexec(regs);
- bust_spinlocks(0);
+ bust_spinlocks(1);
die_owner = -1;
add_taint(TAINT_DIE, LOCKDEP_NOW_UNRELIABLE);
die_nest_count--;
--
2.25.1
Powered by blists - more mailing lists