Skip to contentSkip to conversation

x86/bug: Don't actually invoke printf validation to avoid double-evaluation

PATCH New Sean Christopherson 1 participant 1 message Jul 28 x86

lore
Share & tools
lore
#0 lore raw

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")
---
 arch/x86/include/asm/bug.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/include/asm/bug.h +1 -1
index 23ab05438269..b7916cb85d7b 100644
@@ -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