From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fhigh-b1-smtp.messagingengine.com (fhigh-b1-smtp.messagingengine.com [202.12.124.152]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 330451EFF8D; Sun, 5 Apr 2026 18:18:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.152 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775413086; cv=none; b=a7yC6aAvVT/FdFTKY/HyPcqO/PH8dFDoSdjWIPYRJdLAiWWHw6Zh0I7KgBavrEJzN+mVKSoLEwgvIq6kughsV1Ae33Zia+nUzIZU/gSJ3HxSjP5Rzn0w7+CPZO1BvcK/it4u0CNXKg+i3fVuOsL5w/Hwn9fH5CiEWafxkBkMDmQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775413086; c=relaxed/simple; bh=baSEn/tH018JduF5lZ8JVDyQzWnDpMI1dwiJtO5j3NE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=SVrD8e+u0o7N4gz9DjVyhvdmpsplA0XgM5soXq73Z/TAc4Gzjf2IHKf5SBfMoL2k8ul2dXW76larZKeOuov43c0B2sJ7h7F7ih+bLnbD0ij+q/clK/OOn8VQ/W6lqL3gvhbFT6IJBDzwj4zn8OCv++YjMHTs+WHfSWvuYnoeF/s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=kroah.com; spf=pass smtp.mailfrom=kroah.com; dkim=pass (2048-bit key) header.d=kroah.com header.i=@kroah.com header.b=paN7pvhA; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=oWU7C/po; arc=none smtp.client-ip=202.12.124.152 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=kroah.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kroah.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kroah.com header.i=@kroah.com header.b="paN7pvhA"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="oWU7C/po" Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfhigh.stl.internal (Postfix) with ESMTP id 4CCDF7A011B; Sun, 5 Apr 2026 14:18:02 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-02.internal (MEProxy); Sun, 05 Apr 2026 14:18:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kroah.com; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1775413082; x=1775499482; bh=VKse5fqVEv fxMtlvTxKZmnEXUMDQAUXudTmIffgzBDs=; b=paN7pvhApZuM2yGdbHLnbf7hym V4fhQ1UomSfUNCv0i1IWrC/4LRyIwl2KPM0+TATTmTns0H3mzn7ZSo6VtlW8LMmx Jsa+FU4lYaq4vXIXLATkA5niQCkZDkXgliifJa3AhuNGKulaf+lNDZZK+Mqy9All KFF0nsg2poloF69radlSGiogVxp1MjB8+2AVtrRKEJcD0IAmus9mmgQAe4R0gaed EKMKeFFG3Dkw2K5mbwYCwBc7TnWzRnAQZd3EJIivL+AoqnWzCDHojNbumlnus6Nt gpSFHjA1+zPjWhxd/8DIJUr1hdbZC96CQqZARKtRtNIcL9KT5UJCASvuYbIQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1775413082; x=1775499482; bh=VKse5fqVEvfxMtlvTxKZmnEXUMDQAUXudTm IffgzBDs=; b=oWU7C/ponrYCFU+INHjzFjKsTiNXYEoMMWG01zjtLmcWC4sM4UH XkZEhHMNRQDa33S1nRYcL8N9mLo8djg6bLDAsfYEi3Nf0JvuuFeK9gg2CzBNa77b MOufvrCGLithUtfX46noqRdIFwjeHsg6vsHJfU7WCqnntJsN/OrCIF0BxIpC28b9 KEEumTCOr+bbstLQ1hqQdPivrxOblaXvhQJlGApXAqOHQ6F7fb+IINZuCmz5ISv5 gPivxtAlj/y9aQapJvLLfdg9Qw78NSFtXxhDmqacSdgfZJ5XAeijO98TjGGL2lXV VkfvE3KuzYw0VZjVzSdO5cD5zNpDnaiXEHQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdduheegjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpeffhffvvefukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpefirhgvghcumffj uceoghhrvghgsehkrhhorghhrdgtohhmqeenucggtffrrghtthgvrhhnpeegheeuhefgtd eluddtleekfeegjeetgeeikeehfeduieffvddufeefleevtddtvdenucffohhmrghinhep khgvrhhnvghlrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrg hilhhfrhhomhepghhrvghgsehkrhhorghhrdgtohhmpdhnsggprhgtphhtthhopedukedp mhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepthgrmhhirhgusehkvghrnhgvlhdroh hrghdprhgtphhtthhopehpmhhlrgguvghksehsuhhsvgdrtghomhdprhgtphhtthhopehr ohhsthgvughtsehgohhoughmihhsrdhorhhgpdhrtghpthhtoheprghnughrihihrdhshh gvvhgthhgvnhhkoheslhhinhhugidrihhnthgvlhdrtghomhdprhgtphhtthhopehlihhn uhigsehrrghsmhhushhvihhllhgvmhhovghsrdgukhdprhgtphhtthhopehsvghnohiihh grthhskhihsegthhhrohhmihhumhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghr nhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehsthgrsghlvgesvh hgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlkhhpsehinhhtvghlrdgtohhm X-ME-Proxy: Feedback-ID: i787e41f1:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 5 Apr 2026 14:18:00 -0400 (EDT) Date: Sun, 5 Apr 2026 20:17:34 +0200 From: Greg KH To: Tamir Duberstein Cc: Petr Mladek , Steven Rostedt , Andy Shevchenko , Rasmus Villemoes , Sergey Senozhatsky , linux-kernel@vger.kernel.org, stable@vger.kernel.org, kernel test robot Subject: Re: [PATCH] printf: mark errptr() noinline Message-ID: <2026040530-sullen-overheat-a648@gregkh> References: <20260405-printf-test-old-gcc-v1-1-76d24d9bb60e@kernel.org> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260405-printf-test-old-gcc-v1-1-76d24d9bb60e@kernel.org> On Sun, Apr 05, 2026 at 01:31:50PM -0400, Tamir Duberstein wrote: > Old GCC can miscompile printf_kunit's errptr() test when branch > profiling is enabled. BUILD_BUG_ON(IS_ERR(PTR)) is a constant false > expression, but CONFIG_TRACE_BRANCH_PROFILING and > CONFIG_PROFILE_ALL_BRANCHES make the IS_ERR() path side-effectful. > GCC's IPA splitter can then outline the cold assert arm into > errptr.part.* and leave that clone with an unconditional > __compiletime_assert_*() call, causing a false build failure. > > This started showing up after test_hashed() became a macro and moved its > local buffer into errptr(), which changed GCC's inlining and splitting > decisions enough to expose the compiler bug. > > Mark errptr() noinline to keep it out of that buggy IPA path while > preserving the BUILD_BUG_ON(IS_ERR(PTR)) check and the macro-based > printf argument checking. > > Fixes: 9bfa52dac27a ("printf: convert test_hashed into macro") > Reported-by: kernel test robot > Closes: https://lore.kernel.org/oe-kbuild-all/202604030636.NqjaJvYp-lkp@intel.com/ > Signed-off-by: Tamir Duberstein > --- > lib/tests/printf_kunit.c | 18 +++++++++++++++++- > 1 file changed, 17 insertions(+), 1 deletion(-) > > diff --git a/lib/tests/printf_kunit.c b/lib/tests/printf_kunit.c > index f6f21b445ece..a8087e8ac826 100644 > --- a/lib/tests/printf_kunit.c > +++ b/lib/tests/printf_kunit.c > @@ -749,7 +749,23 @@ static void fourcc_pointer(struct kunit *kunittest) > fourcc_pointer_test(kunittest, try_cb, ARRAY_SIZE(try_cb), "%p4cb"); > } > > -static void > +/* > + * GCC < 12.1 can miscompile this test when branch profiling is enabled. > + * > + * BUILD_BUG_ON(IS_ERR(PTR)) is a constant false expression, but old GCC can > + * still trip over it after CONFIG_TRACE_BRANCH_PROFILING and > + * CONFIG_PROFILE_ALL_BRANCHES rewrite the IS_ERR() unlikely() path into > + * side-effectful branch counter updates. IPA splitting then outlines the cold > + * assert arm into errptr.part.* and leaves that clone with an unconditional > + * __compiletime_assert_*() call, so the build fails even though PTR is not an > + * ERR_PTR. > + * > + * Keep this test out of that buggy IPA path so the BUILD_BUG_ON() can stay in > + * place without open-coding IS_ERR(). This can be removed once the minimum GCC > + * includes commit 76fe49423047 ("Fix tree-optimization/101941: IPA splitting > + * out function with error attribute"), which first shipped in GCC 12.1. > + */ > +static noinline void > errptr(struct kunit *kunittest) > { > test("-1234", "%pe", ERR_PTR(-1234)); > > --- > base-commit: d8a9a4b11a137909e306e50346148fc5c3b63f9d > change-id: 20260405-printf-test-old-gcc-f13fecda6524 > > Best regards, > -- > Tamir Duberstein > > This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read: https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html for how to do this properly.