x86/bug: Don't actually invoke printf validation to avoid double-evaluation
PATCH 1/1 x86/bug: Don't actually invoke printf validation to avoid double-evaluation
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 <[email protected]>
Signed-off-by Sean Christopherson <[email protected]>
--- arch/x86/include/asm/bug.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/include/asm/bug.h +1 -1
@@ -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
Signature · 1 line
2.55.0.229.g6434b31f56-goog