Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

x86/bug: Handle __WARN_printf() trap in early_fixup_exception()

The commit 5b472b6e5bd9 ("x86_64/bug: Implement __WARN_printf()")
implemented __WARN_printf(), which changed the mechanism to use UD1
instead of UD2. However, it only handles the trap in the runtime IDT
handler, while the early booting IDT handler lacks this handling. As a
result, the usage of WARN() before the runtime IDT setup can lead to
kernel crashes. Since KMSAN is enabled after the runtime IDT setup, it
is safe to use handle_bug() directly in early_fixup_exception() to
address this issue.

Fixes: 5b472b6e5bd9 ("x86_64/bug: Implement __WARN_printf()")
Signed-off-by: Hou Wenlong <houwenlong.hwl@antgroup.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/c4fb3645f60d3a78629d9870e8fcc8535281c24f.1768016713.git.houwenlong.hwl@antgroup.com

authored by

Hou Wenlong and committed by
Peter Zijlstra
a0cb371b aa280a08

+5 -6
+2
arch/x86/include/asm/traps.h
··· 25 25 void handle_invalid_op(struct pt_regs *regs); 26 26 #endif 27 27 28 + noinstr bool handle_bug(struct pt_regs *regs); 29 + 28 30 static inline int get_si_code(unsigned long condition) 29 31 { 30 32 if (condition & DR_STEP)
+1 -1
arch/x86/kernel/traps.c
··· 397 397 ILL_ILLOPN, error_get_trap_addr(regs)); 398 398 } 399 399 400 - static noinstr bool handle_bug(struct pt_regs *regs) 400 + noinstr bool handle_bug(struct pt_regs *regs) 401 401 { 402 402 unsigned long addr = regs->ip; 403 403 bool handled = false;
+2 -5
arch/x86/mm/extable.c
··· 411 411 return; 412 412 413 413 if (trapnr == X86_TRAP_UD) { 414 - if (report_bug(regs->ip, regs) == BUG_TRAP_TYPE_WARN) { 415 - /* Skip the ud2. */ 416 - regs->ip += LEN_UD2; 414 + if (handle_bug(regs)) 417 415 return; 418 - } 419 416 420 417 /* 421 - * If this was a BUG and report_bug returns or if this 418 + * If this was a BUG and handle_bug returns or if this 422 419 * was just a normal #UD, we want to continue onward and 423 420 * crash. 424 421 */