arm64: traps: disable irq in die()
authorQiao Zhou <qiaozhou@asrmicro.com>
Fri, 7 Jul 2017 09:29:34 +0000 (17:29 +0800)
committerBen Hutchings <ben@decadent.org.uk>
Sat, 11 Jan 2020 02:04:48 +0000 (02:04 +0000)
commit 6f44a0bacb79a03972c83759711832b382b1b8ac upstream.

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 <qiaozhou@asrmicro.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
arch/arm64/kernel/traps.c

index d368cc98bcdb49dff655a51d0b28425477f13f13..a81da68aa65abc09f0768275001c34a9340142dd 100644 (file)
@@ -178,10 +178,12 @@ void die(const char *str, struct pt_regs *regs, int err)
 {
        struct thread_info *thread = current_thread_info();
        int ret;
+       unsigned long flags;
+
+       raw_spin_lock_irqsave(&die_lock, flags);
 
        oops_enter();
 
-       raw_spin_lock_irq(&die_lock);
        console_verbose();
        bust_spinlocks(1);
        ret = __die(str, err, thread, regs);
@@ -191,13 +193,15 @@ void die(const char *str, struct pt_regs *regs, int err)
 
        bust_spinlocks(0);
        add_taint(TAINT_DIE, LOCKDEP_NOW_UNRELIABLE);
-       raw_spin_unlock_irq(&die_lock);
        oops_exit();
 
        if (in_interrupt())
                panic("Fatal exception in interrupt");
        if (panic_on_oops)
                panic("Fatal exception");
+
+       raw_spin_unlock_irqrestore(&die_lock, flags);
+
        if (ret != NOTIFY_STOP)
                do_exit(SIGSEGV);
 }