From nobody Wed Jun 17 07:15:32 2026 Received: from mail-pg1-f201.google.com (mail-pg1-f201.google.com [209.85.215.201]) (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 CF7CF242D9B for ; Thu, 23 Apr 2026 14:54:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776956067; cv=none; b=hyzBd2CEnzsUiWl8vW4TcRagQP8RPGug+2D/JY8wRLban/1QPIwpPeSPrK+1QbGLSzYZWPxnk4upvbLa79EJ9azlJQJLWH6QEw3r5apJc4oUS4ItfSkRjJgVNIx88wA/Pd0Ic/Fpq1la6Wy/zQizOmXS9ENQ7dw602khQyYGrIo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776956067; c=relaxed/simple; bh=zU+tj/df5c0qGETZJCIieQCwXEKc5AyaT/+uQoqdivw=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=lx+sFBw313E198M5j5IfjAgDgabWoYBtQWxQjdyqu2tFh9j5PiJXhHSrFxEHGbxps+b2YpDbuZaAYirLBCelRT/koli/46sZe4gnumsJ9LOpn0weAaT9YBILJU5eBt6mB7gvD4EPn9M2rVeknXkeHRPM2gPbpg6XVY3Z+ZQEn3c= 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=arFKnJ3+; arc=none smtp.client-ip=209.85.215.201 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="arFKnJ3+" Received: by mail-pg1-f201.google.com with SMTP id 41be03b00d2f7-b62da7602a0so3549598a12.2 for ; Thu, 23 Apr 2026 07:54:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776956065; x=1777560865; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=z4reAZlMsUrVzum9p0YSA33pO2Ve/EDZX4eovaEjQdk=; b=arFKnJ3+saCpBFqYBmQhQk2mIimD1bTyFzTqsrrVB063AiTOmmdSlaPSXnVvTo0Gxd r3pwYigBvVDhTMbfuDRYZpkRoxZTloRVMyhcDQLCMa4+79ecI9FbcQIf/zPNz+nN2snb WU9hR/DfHLfFjflWBnRlUM4X+XTJKhaokzul93GS5btudi0eEqPfCgtIuiEXrCiQ/XTv 6+5VTOaUnEi4TnOBpOsXKFkfvxkKh15DkgD4dQL8qtXQ0xFO/uDfMOX8D15wjoA6V/hC iqweNsgWBDO0n+TtwU5raTaO/jKFoWad5WFJEGq/LFOOXZgwf336Ly6dUXVktYHkA1Ex g9Ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776956065; x=1777560865; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=z4reAZlMsUrVzum9p0YSA33pO2Ve/EDZX4eovaEjQdk=; b=pTS399O+Yk4hMhtXTr+DYaY+IljWCS1qtuYxlthPD3rDucHD4TyTNgepgCpruzYI2e gqLVozLNpv9PXbfuMn3ieMmWN0ME8y68H1wbpTxoAbMsBwxaQPz87wAf22yW2HOqVCFy s68Z1OD/o/Dwlf0blGJTTR2U0Abzq3VfrSXQsSnRxSCAS+tIgCFcMceUBbnE66J0dcmt v7sEPGB39A/KMxYadnuXSynFgw8aZkGTuxZc5w5200WYCoZvJRbCMCMEFs0IslPA1NEF BwmhftbFHwzZNOdJZ1ViGn0t1EnKZpE+r5+TDbOKkgBBdtcJLhoLJ6bX7bCVQORiTDN/ 9vzw== X-Gm-Message-State: AOJu0YyYFdxCH2NNivbi3SHmqRMcbTmWh1ZaSjiDvNs6EhFvDb8bBUt1 EF5H/rKwREMuKEccfLnRpszOZWa6lkOr4oij4PlCDa/ym/aj/ZUOPGZ8B9Slx3r/gt6sb+4p4cf SLSMIgQ== X-Received: from pgib18.prod.google.com ([2002:a63:e712:0:b0:c73:cc95:c0d7]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:a12b:b0:3a2:dafd:3c02 with SMTP id adf61e73a8af0-3a2dafd4cd8mr19691115637.19.1776956064896; Thu, 23 Apr 2026 07:54:24 -0700 (PDT) Reply-To: Sean Christopherson Date: Thu, 23 Apr 2026 07:54:17 -0700 In-Reply-To: <20260423145419.459988-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260423145419.459988-1-seanjc@google.com> X-Mailer: git-send-email 2.54.0.545.g6539524ca2-goog Message-ID: <20260423145419.459988-2-seanjc@google.com> Subject: [PATCH v2 1/2] x86/bug: Add printf() validation to HAVE_ARCH_BUG_FORMAT_ARGS WARNs From: Sean Christopherson To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org Cc: linux-kernel@vger.kernel.org, Yan Zhao , Peter Zijlstra , Sean Christopherson Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add explicit printf() validation for x86-64's newfangled WARN implementation, as most (all?) compilers fail to detect basic formatting issues without the annotation. E.g. even goofs like printing a u64 as a string aren't detected: WARN_ONCE(1, "Bad message, %s", vcpu->arch.last_guest_tsc); Lack of validation is especially problematic for code that is 64-bit-only, as blatant goofs can easily go unnoticed, as they (somewhat ironically) will only be noticed by CONFIG_BUG=3Dn builds. Cc: Yan Zhao Cc: Peter Zijlstra (Intel) Link: https://lore.kernel.org/all/adc1IrD8uqWdaOKv@yzhao56-desk.sh.intel.com Fixes: 5b472b6e5bd9 ("x86_64/bug: Implement __WARN_printf()") Fixes: 11bb4944f014 ("x86/bug: Implement WARN_ONCE()") Signed-off-by: Sean Christopherson Acked-by: Dave Hansen --- arch/x86/include/asm/bug.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/x86/include/asm/bug.h b/arch/x86/include/asm/bug.h index 80c1696d8d59..bf3c802654d1 100644 --- a/arch/x86/include/asm/bug.h +++ b/arch/x86/include/asm/bug.h @@ -153,6 +153,7 @@ struct arch_va_list { struct sysv_va_list args; }; extern void *__warn_args(struct arch_va_list *args, struct pt_regs *regs); +static __always_inline __printf(1, 2) void __WARN_validate_printf(const ch= ar *fmt, ...) { } #endif /* __ASSEMBLER__ */ =20 #define __WARN_bug_entry(flags, format) ({ \ @@ -172,6 +173,7 @@ extern void *__warn_args(struct arch_va_list *args, str= uct pt_regs *regs); #define __WARN_print_arg(flags, format, arg...) \ do { \ int __flags =3D (flags) | BUGFLAG_WARNING | BUGFLAG_ARGS ; \ + __WARN_validate_printf(format, ## arg); \ static_call_mod(WARN_trap)(__WARN_bug_entry(__flags, format), ## arg); \ asm (""); /* inhibit tail-call optimization */ \ } while (0) --=20 2.54.0.545.g6539524ca2-goog From nobody Wed Jun 17 07:15:32 2026 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (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 C90DB2222CC for ; Thu, 23 Apr 2026 14:54:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776956069; cv=none; b=klrhhYr6GRUEEV877GeiDvLNN8enW17OBcCnaE7Re2GLmgTyKok5MM93y7yUTG5re3G4979OPlrCNj6OeRXka1MPrNzCYR0mjXF5Y3KDUofJFlrvWTGSxIaofM9dsT52wcdu2fprNi17MaGa0rDmsYdWRrjWuLjj1tv5nuWpLqE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776956069; c=relaxed/simple; bh=pdm9TcX74XP6LiaHNj5XN1HMZh8tdya3qAl40cMcKM8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=eHjMukmmbRITge/m3u6yeAWwWk5Td4y4i+kLlQksdoH1T3XYXy+/GAu/QdtCsQMsfY96B4dCr7JRwuTgQw/j2adq5zSBfhUaQMbMzLybmZxnJvoSn2SyBVJiLPl+M/uvc/x8E+tb9dHm5UCA8DO0x9OuVdjZtzVJTok/JDZypjk= 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=NeqvdRO5; arc=none smtp.client-ip=209.85.216.74 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="NeqvdRO5" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-3568090851aso16526916a91.1 for ; Thu, 23 Apr 2026 07:54:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776956067; x=1777560867; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=2P1kNNlr+l7rWDJSe4GMuyvELV87LFagI2u8Vl0t5r4=; b=NeqvdRO5Dna1VknXeQPd8LLoILWffd9BQlSPPDkkOmBKp6X1x/r65YGA+FEI/MnqRM 1bQOGHrQN3YsWsm7ak0jcvM/uSiwOb8Wj67QSxHGENbDSuUW8mOSoH1LFGoXjYu4MSal rmRl5c5eRHcij+nRJN329LsU1m3F919VmgyFSUWk7aNUnYiJ45NTtfSZybqQmZ4CeyLj 2x1t1KQQ7Wnff4ijX0XjLLZg5SYdbP7xIhyxibqQEAqybXbuFgAKyqDEAcihM6aRRhcr 0vE41gUstDLNJ8csiwAYIa4KuCuIeXCxl4P4njgLaFbY0cKQtXUnfIs4c3LQgLyBZyOo VJhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776956067; x=1777560867; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=2P1kNNlr+l7rWDJSe4GMuyvELV87LFagI2u8Vl0t5r4=; b=k0ej7d3GyeXLnLoMayf0+GKIUgwrdDDhX90yc5pkRmCC1BlKurb0Vh10zg1gbU98dN kdL4I3uZdUATl4Ap647crNNN2KmciTFlAKyBZBE1N85X5RNHUbB/Ga3fOch/afkj974J TyrLUNI0v5FFNG99e0mG8NxC1l72xHe24UXiliapLIsML8W33b4aSl6L+TAOahTAH/aM h/7NE8w06gazBPDwLivsO0xnBY4tBaY8LiQu9f810m6anOe2RmXRjrjkQq+172W4Vi0d +9SHv1bd8jqqqjl/hs1PdMzKTzRljZPEdl+ftT7P4IJBarKsoasNjkh5oKnAO2QWeYi0 ZdmQ== X-Gm-Message-State: AOJu0YxTaMYmp33vp57zXMRYhjJWayUTeG2EW9/q9SkyvyTw7e+uwKVY vkBLGNw4IcZHbcWu8eb/GqqDoyQhYNp7x79KecKK2Zr3U1dvnoBR4aPKJ7Ca0dl0TvGgjGDgwN4 SnyITfQ== X-Received: from plcj14.prod.google.com ([2002:a17:902:f24e:b0:2b2:55c3:7398]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:2fc8:b0:35d:a542:2dc4 with SMTP id 98e67ed59e1d1-3614047a7b8mr29921640a91.21.1776956066907; Thu, 23 Apr 2026 07:54:26 -0700 (PDT) Reply-To: Sean Christopherson Date: Thu, 23 Apr 2026 07:54:18 -0700 In-Reply-To: <20260423145419.459988-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260423145419.459988-1-seanjc@google.com> X-Mailer: git-send-email 2.54.0.545.g6539524ca2-goog Message-ID: <20260423145419.459988-3-seanjc@google.com> Subject: [PATCH v2 2/2] x86/bug: Put HAVE_ARCH_BUG_FORMAT_ARGS WARN definitions inside __ASSEMBLER__ From: Sean Christopherson To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org Cc: linux-kernel@vger.kernel.org, Yan Zhao , Peter Zijlstra , Sean Christopherson Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Extend the !assembly #ifdef guarding x86's custom WARN helpers to cover the WARN macros themselves, as they aren't assembly friendly. This helps make it clear that things like __WARN_validate_printf() don't need a dummy definition for assembly code. No functional change intended. Suggested-by: Yan Zhao 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 bf3c802654d1..23ab05438269 100644 --- a/arch/x86/include/asm/bug.h +++ b/arch/x86/include/asm/bug.h @@ -154,7 +154,6 @@ struct arch_va_list { }; extern void *__warn_args(struct arch_va_list *args, struct pt_regs *regs); static __always_inline __printf(1, 2) void __WARN_validate_printf(const ch= ar *fmt, ...) { } -#endif /* __ASSEMBLER__ */ =20 #define __WARN_bug_entry(flags, format) ({ \ struct bug_entry *bug; \ @@ -189,6 +188,7 @@ do { \ } \ __ret_warn_on; \ }) +#endif /* __ASSEMBLER__ */ =20 #endif /* HAVE_ARCH_BUG_FORMAT_ARGS */ =20 --=20 2.54.0.545.g6539524ca2-goog