From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 439673AB269 for ; Tue, 28 Jul 2026 13:39:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.198 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785245953; cv=none; b=pHf0mZcH043Iind86gVaKIwhT0p8X1dQugiO3WDd58TZX/zULngb1xRS83QdgBBrb2u5WeID5Cdoow1nyoMLMKcwODEiwqSCe+Dz8HQ1DHnf/OW3J3twJs6wU4hjUbNAP5KsFJug4QNkuX1vxgxARYEBX1ImsVaURC5F2sZnDFE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785245953; c=relaxed/simple; bh=RiB8WU/U2++oe4Eyc27/5kyqDKtqw7LWxhZvtuIB6KQ=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=HROECrWsC8iJkQC0NpWD8g9ZE3Os9czld/wmE/jsJ91DfTFhtZVStcJlwqEgPrKAxiqfJavXqsEptbuGxG40rfA/TYpRczJm3abR5FroFl03puZTjudDpZXLx+sbZCQ31IS1ZN1B5WmYsLXKl/LXwyCkRz7JJ5I9MXCMywfr1oU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=hLWhtUdz; arc=none smtp.client-ip=209.85.210.198 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="hLWhtUdz" Received: by mail-pf1-f198.google.com with SMTP id d2e1a72fcca58-84877b362f6so6675436b3a.2 for ; Tue, 28 Jul 2026 06:39:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1785245951; x=1785850751; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:mime-version:date :reply-to:from:to:cc:subject:date:message-id:reply-to:content-type; bh=z9aTcSnV/D1s2UPX1l1lCNTCUfwVtmCI0yWAA1veuGw=; b=hLWhtUdze+MTDSZCRAUxqiQ1GCNr5cmqqaNRuJeuk9Stmz08E2+GWs9vbPzCYZxLet r8xftkTy2orbUIQuUi4VyM8nMcrXd0w3pWjwUpjQNnP9/Q1mvWpAN60iWrMBta8gYsVM Vzef2/QgwvgYE57PJizLOrP1AwzUcVBTp4J0u5Eii6odUYfa5ntrkOMWTMK7XIviKy2w Q2RBvaUGZh6HwY/9oDzjcFrYp/sYQXwny9uzIr4IvO48gxuIFIZla8dr33aJsjSR5uU8 +q4sVZwKuk0rKbj6oF+irPwN6dR22qpVg+6FrCrKhRwNIuVA3OSoDVdwaXoiC15VPicf or7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785245951; x=1785850751; h=content-type:cc:to:from:subject:message-id:mime-version:date :reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=z9aTcSnV/D1s2UPX1l1lCNTCUfwVtmCI0yWAA1veuGw=; b=MgOE4f2M9P5Z9CQJjiMjfOwTp9zraSjgzr6ImpQ+H8qO73GK23f4dW1cHfPbU0R8wK Y2btT0SuCv/nL8HLmCPfWaqz+gWCVNmX9VIJSWPMpjQzbpGlmPWUryAQbjsjzNzSOU+b K2VhmzTYpXnWBJJgK3Thk8+KskIwr1myQYkhI7S5DHh8Bvp2YF7EeyM2C2UHt/Ko85Br cMBWdH2DmrezHXOSALqN79XrBelU3yEJ8d2XzpFZjJIZpIb7RSUekP/3ZILhoxxbgq3y Hjul6PamVCkcvs2XBUGNg+MPqaTRtAh88NwLQfqGZ+zGY7MfQ5E7sNhNHIFHczqmI774 CHrg== X-Forwarded-Encrypted: i=1; AHgh+RrKWqkoXfzChW1J5CkyiPEDFHSLRzd7VcXcXV7V/R3v3ZXpcFynzxi0ksa6tqZ6J/otbCjtaWuIhHaDUrQ=@vger.kernel.org X-Gm-Message-State: AOJu0YwwdbbgFqZl2ikgsmZgDPSkm5zFZAUIQaqnGUOkGAUcLgf5pqtn TMMV9TT9MhJnGMOi7JYHg+Zm3wdGLdg+yQOHpf8iXVBWJ2+gssk/9C7jV9JjW9Lg1zhhHSsNvmE /jis/Gg== X-Received: from pghq1.prod.google.com ([2002:a63:e201:0:b0:cb4:a110:e902]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:4488:b0:84c:2d22:730d with SMTP id d2e1a72fcca58-84e9317c153mr2461088b3a.29.1785245951278; Tue, 28 Jul 2026 06:39:11 -0700 (PDT) Reply-To: Sean Christopherson Date: Tue, 28 Jul 2026 06:39:09 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.55.0.229.g6434b31f56-goog Message-ID: <20260728133910.982881-1-seanjc@google.com> Subject: [PATCH] x86/bug: Don't actually invoke printf validation to avoid double-evaluation From: Sean Christopherson To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org Cc: "H. Peter Anvin" , linux-kernel@vger.kernel.org, Brad Spengler , Sean Christopherson Content-Type: text/plain; charset="UTF-8" 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 Signed-off-by: Sean Christopherson --- 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