From: Sean Christopherson <seanjc@google.com>
To: Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org
Cc: "H. Peter Anvin" <hpa@zytor.com>,
linux-kernel@vger.kernel.org,
Brad Spengler <brad.spengler@opensrcsec.com>,
Sean Christopherson <seanjc@google.com>
Subject: [PATCH] x86/bug: Don't actually invoke printf validation to avoid double-evaluation
Date: Tue, 28 Jul 2026 06:39:09 -0700 [thread overview]
Message-ID: <20260728133910.982881-1-seanjc@google.com> (raw)
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
reply other threads:[~2026-07-28 13:39 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260728133910.982881-1-seanjc@google.com \
--to=seanjc@google.com \
--cc=bp@alien8.de \
--cc=brad.spengler@opensrcsec.com \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@kernel.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®