Skip to content

Commit 6f44a0b

Browse files
Qiao Zhouwildea01
authored andcommitted
arm64: traps: disable irq in die()
In current die(), the irq is disabled for __die() handle, not including the possible panic() handling. Since the log in __die() can take several hundreds ms, new irq might come and interrupt current die(). If the process calling die() holds some critical resource, and some other process scheduled later also needs it, then it would deadlock. The first panic will not be executed. So here disable irq for the whole flow of die(). Signed-off-by: Qiao Zhou <[email protected]> Signed-off-by: Will Deacon <[email protected]>
1 parent 32fb5d7 commit 6f44a0b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

arch/arm64/kernel/traps.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,10 +274,12 @@ static DEFINE_RAW_SPINLOCK(die_lock);
274274
void die(const char *str, struct pt_regs *regs, int err)
275275
{
276276
int ret;
277+
unsigned long flags;
278+
279+
raw_spin_lock_irqsave(&die_lock, flags);
277280

278281
oops_enter();
279282

280-
raw_spin_lock_irq(&die_lock);
281283
console_verbose();
282284
bust_spinlocks(1);
283285
ret = __die(str, err, regs);
@@ -287,13 +289,15 @@ void die(const char *str, struct pt_regs *regs, int err)
287289

288290
bust_spinlocks(0);
289291
add_taint(TAINT_DIE, LOCKDEP_NOW_UNRELIABLE);
290-
raw_spin_unlock_irq(&die_lock);
291292
oops_exit();
292293

293294
if (in_interrupt())
294295
panic("Fatal exception in interrupt");
295296
if (panic_on_oops)
296297
panic("Fatal exception");
298+
299+
raw_spin_unlock_irqrestore(&die_lock, flags);
300+
297301
if (ret != NOTIFY_STOP)
298302
do_exit(SIGSEGV);
299303
}

0 commit comments

Comments
 (0)