From: David Gow Date: Thu, 2 Feb 2023 04:42:41 +0000 (-0800) Subject: mm: kasan: do not panic if both panic_on_warn and kasan_multishot set X-Git-Tag: baikal/aarch64/sdk5.9~20 X-Git-Url: https://git.baikalelectronics.ru/sdk/?a=commitdiff_plain;h=aceb8d174963a7f7896450ed0f406d5266df00f1;p=kernel.git mm: kasan: do not panic if both panic_on_warn and kasan_multishot set commit d6e893addabaab95bded928d3a7f2b0b744696d7 upstream. KASAN errors will currently trigger a panic when panic_on_warn is set. This renders kasan_multishot useless, as further KASAN errors won't be reported if the kernel has already paniced. By making kasan_multishot disable this behaviour for KASAN errors, we can still have the benefits of panic_on_warn for non-KASAN warnings, yet be able to use kasan_multishot. This is particularly important when running KASAN tests, which need to trigger multiple KASAN errors: previously these would panic the system if panic_on_warn was set, now they can run (and will panic the system should non-KASAN warnings show up). Signed-off-by: David Gow Signed-off-by: Andrew Morton Tested-by: Andrey Konovalov Reviewed-by: Andrey Konovalov Reviewed-by: Brendan Higgins Cc: Andrey Ryabinin Cc: Dmitry Vyukov Cc: Ingo Molnar Cc: Juri Lelli Cc: Patricia Alfonso Cc: Peter Zijlstra Cc: Shuah Khan Cc: Vincent Guittot Link: https://lkml.kernel.org/r/20200915035828.570483-6-davidgow@google.com Link: https://lkml.kernel.org/r/20200910070331.3358048-6-davidgow@google.com Signed-off-by: Linus Torvalds Signed-off-by: Eric Biggers Signed-off-by: Sasha Levin --- diff --git a/mm/kasan/report.c b/mm/kasan/report.c index 621782100eaa0..a05ff1922d499 100644 --- a/mm/kasan/report.c +++ b/mm/kasan/report.c @@ -92,7 +92,7 @@ static void end_report(unsigned long *flags) pr_err("==================================================================\n"); add_taint(TAINT_BAD_PAGE, LOCKDEP_NOW_UNRELIABLE); spin_unlock_irqrestore(&report_lock, *flags); - if (panic_on_warn) + if (panic_on_warn && !test_bit(KASAN_BIT_MULTI_SHOT, &kasan_flags)) panic("panic_on_warn set ...\n"); kasan_enable_current(); }