[PATCH 3/5] kcsan: unset panic_on_warn before calling panic()

Tiezhu Yang yangtiezhu at loongson.cn
Fri Jan 28 03:42:23 PST 2022


As done in the full WARN() handler, panic_on_warn needs to be cleared
before calling panic() to avoid recursive panics.

Signed-off-by: Tiezhu Yang <yangtiezhu at loongson.cn>
---
 kernel/kcsan/report.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/kernel/kcsan/report.c b/kernel/kcsan/report.c
index 6779440..752ab33 100644
--- a/kernel/kcsan/report.c
+++ b/kernel/kcsan/report.c
@@ -492,8 +492,16 @@ static void print_report(enum kcsan_value_change value_change,
 	dump_stack_print_info(KERN_DEFAULT);
 	pr_err("==================================================================\n");
 
-	if (panic_on_warn)
+	if (panic_on_warn) {
+		/*
+		 * This thread may hit another WARN() in the panic path.
+		 * Resetting this prevents additional WARN() from panicking the
+		 * system on this thread.  Other threads are blocked by the
+		 * panic_mutex in panic().
+		 */
+		panic_on_warn = 0;
 		panic("panic_on_warn set ...\n");
+	}
 }
 
 static void release_report(unsigned long *flags, struct other_info *other_info)
-- 
2.1.0




More information about the kexec mailing list