[PATCH] x86/bug: Don't actually invoke printf validation to avoid double-evaluation
From: Sean Christopherson
Date: Tue Jul 28 2026 - 09:40:36 EST
As pointed out by ChatGPT's Codex, invoking __WARN_validate_printf() can
result in double-evaluation of the arguments even though the function is
always inlined and empty. Guard the call with "if (0)" so that the code
never actually runs (the possibility of the function call is sufficient to
detect formatting issues).
Fixes: 40c4b47f41b9 ("x86/bug: Add printf() validation to HAVE_ARCH_BUG_FORMAT_ARGS WARNs")
Suggested-by: Brad Spengler <brad.spengler@xxxxxxxxxxxxxx>
Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>
---
arch/x86/include/asm/bug.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/include/asm/bug.h b/arch/x86/include/asm/bug.h
index 23ab05438269..b7916cb85d7b 100644
--- a/arch/x86/include/asm/bug.h
+++ b/arch/x86/include/asm/bug.h
@@ -172,7 +172,7 @@ static __always_inline __printf(1, 2) void __WARN_validate_printf(const char *fm
#define __WARN_print_arg(flags, format, arg...) \
do { \
int __flags = (flags) | BUGFLAG_WARNING | BUGFLAG_ARGS ; \
- __WARN_validate_printf(format, ## arg); \
+ if (0) __WARN_validate_printf(format, ## arg); \
static_call_mod(WARN_trap)(__WARN_bug_entry(__flags, format), ## arg); \
asm (""); /* inhibit tail-call optimization */ \
} while (0)
base-commit: 36ca470a6c1c76e999117d6b1799fd5d3bb0985b
--
2.55.0.229.g6434b31f56-goog