public inbox for linux-edac@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH] x86/mce/inject: Add sanity check in inject_mce()
@ 2025-05-29  3:32 Xiongfeng Wang
  2025-05-29  9:45 ` Borislav Petkov
  0 siblings, 1 reply; 8+ messages in thread
From: Xiongfeng Wang @ 2025-05-29  3:32 UTC (permalink / raw)
  To: tony.luck, bp; +Cc: x86, linux-edac, wanghai38, bobo.shaobowang, wangxiongfeng2

syzbot reported the following kernel panic:

[  306.335489][ T3298] mce: CPUs not responding to MCE broadcast (may include false positives): 1-3
[  306.336332][ T3298] Kernel panic - not syncing: Timeout: Not all CPUs entered broadcast exception handler
[  306.337786][ T3298] Kernel Offset: 0x17400000 from 0xffffffff81000000 (relocation range: 0xffffffff80000000-0xffffffffbfffffff)

The syzkaller test didn't set 'MCJ_IRQ_BROADCAST | MCJ_NMI_BROADCAST' in
'inject_flags', so the MCE will only be injected to the local CPU. But
'MCG_STATUS_LMCES' is not set in 'mcgstatus', so the local CPU will wait
others CPUs to enter MCE in mce_start(). But other CPUs were not
injected, so the above panic happened. We add sanity check in
inject_mce() to fix this issue.

Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com>
---
 arch/x86/kernel/cpu/mce/inject.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/x86/kernel/cpu/mce/inject.c b/arch/x86/kernel/cpu/mce/inject.c
index 06e3cf7229ce..4af98f0e191e 100644
--- a/arch/x86/kernel/cpu/mce/inject.c
+++ b/arch/x86/kernel/cpu/mce/inject.c
@@ -127,6 +127,13 @@ static void inject_mce(struct mce *m)
 {
 	struct mce *i = &per_cpu(injectm, m->extcpu);
 
+	/* do some sanity checks */
+	if (!(m->inject_flags & (MCJ_IRQ_BROADCAST | MCJ_NMI_BROADCAST))) {
+		if (m->cpuvendor == X86_VENDOR_INTEL ||
+		    m->cpuvendor == X86_VENDOR_ZHAOXIN)
+			m->mcgstatus |= MCG_STATUS_LMCES;
+	}
+
 	/* Make sure no one reads partially written injectm */
 	i->finished = 0;
 	mb();
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-06-11 17:41 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-29  3:32 [RFC PATCH] x86/mce/inject: Add sanity check in inject_mce() Xiongfeng Wang
2025-05-29  9:45 ` Borislav Petkov
2025-05-31  8:14   ` Ingo Molnar
2025-05-31  9:17     ` Borislav Petkov
2025-05-31 18:04       ` Ingo Molnar
2025-05-31 19:07         ` Borislav Petkov
2025-05-31 22:00           ` Luck, Tony
2025-06-11 17:41             ` Yazen Ghannam

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox