Skip to content

Commit 130aee3

Browse files
mnissler-rivospalmer-dabbelt
authored andcommitted
riscv: Avoid enabling interrupts in die()
While working on something else, I noticed that the kernel would start accepting interrupts again after crashing in an interrupt handler. Since the kernel is already in inconsistent state, enabling interrupts is dangerous and opens up risk of kernel state deteriorating further. Interrupts do get enabled via what looks like an unintended side effect of spin_unlock_irq, so switch to the more cautious spin_lock_irqsave/spin_unlock_irqrestore instead. Fixes: 76d2a04 ("RISC-V: Init and Halt Code") Signed-off-by: Mattias Nissler <[email protected]> Reviewed-by: Björn Töpel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Cc: [email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 416721f commit 130aee3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

arch/riscv/kernel/traps.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@ void die(struct pt_regs *regs, const char *str)
3434
static int die_counter;
3535
int ret;
3636
long cause;
37+
unsigned long flags;
3738

3839
oops_enter();
3940

40-
spin_lock_irq(&die_lock);
41+
spin_lock_irqsave(&die_lock, flags);
4142
console_verbose();
4243
bust_spinlocks(1);
4344

@@ -54,7 +55,7 @@ void die(struct pt_regs *regs, const char *str)
5455

5556
bust_spinlocks(0);
5657
add_taint(TAINT_DIE, LOCKDEP_NOW_UNRELIABLE);
57-
spin_unlock_irq(&die_lock);
58+
spin_unlock_irqrestore(&die_lock, flags);
5859
oops_exit();
5960

6061
if (in_interrupt())

0 commit comments

Comments
 (0)