* [PATCH] x86/bug: Don't actually invoke printf validation to avoid double-evaluation
@ 2026-07-28 13:39 Sean Christopherson
0 siblings, 0 replies; only message in thread
From: Sean Christopherson @ 2026-07-28 13:39 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86
Cc: H. Peter Anvin, linux-kernel, Brad Spengler, Sean Christopherson
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@opensrcsec.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-07-28 13:39 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-28 13:39 [PATCH] x86/bug: Don't actually invoke printf validation to avoid double-evaluation Sean Christopherson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®