Skip to content

Commit 1d2252f

Browse files
keestorvalds
authored andcommitted
kasan: unset panic_on_warn before calling panic()
As done in the full WARN() handler, panic_on_warn needs to be cleared before calling panic() to avoid recursive panics. Signed-off-by: Kees Cook <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Acked-by: Dmitry Vyukov <[email protected]> Cc: Alexander Potapenko <[email protected]> Cc: Andrey Konovalov <[email protected]> Cc: Andrey Ryabinin <[email protected]> Cc: Ard Biesheuvel <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Dan Carpenter <[email protected]> Cc: Elena Petrova <[email protected]> Cc: "Gustavo A. R. Silva" <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Linus Torvalds <[email protected]>
1 parent 1d28c8d commit 1d2252f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

mm/kasan/report.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,16 @@ static void end_report(unsigned long *flags)
9292
pr_err("==================================================================\n");
9393
add_taint(TAINT_BAD_PAGE, LOCKDEP_NOW_UNRELIABLE);
9494
spin_unlock_irqrestore(&report_lock, *flags);
95-
if (panic_on_warn)
95+
if (panic_on_warn) {
96+
/*
97+
* This thread may hit another WARN() in the panic path.
98+
* Resetting this prevents additional WARN() from panicking the
99+
* system on this thread. Other threads are blocked by the
100+
* panic_mutex in panic().
101+
*/
102+
panic_on_warn = 0;
96103
panic("panic_on_warn set ...\n");
104+
}
97105
kasan_enable_current();
98106
}
99107

0 commit comments

Comments
 (0)