From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 736D2500941; Sat, 17 Jan 2026 19:07:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768676845; cv=none; b=jaXyfjTwglkYe9V0hVh8rCpW0rqq736eqDl2AVJRyV2/BK526/Emu+zGSpHCV3xw6NgpHjhEnkYN6aVf67IbytqwVwwQoKV3y6oV/x4pESlmbC4990CvuajFL6Q1eXUvt7Bq3eLORDvL98pwiJuxKHFk1YNQH9d1dAjgrnfyMpc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768676845; c=relaxed/simple; bh=wvP+WP9tHXE//mbhVEIHbRHuOfsqiDs/WYK3kZyFGuU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=cgIXjqtbz7iij9XjnkEXvNONtGuBz+2Fr6hWVTfQlqbibE61fMNC8F0lHp2KRDimvRwDMVXS/C6YTbgMZ5s53wY9joYD7aclac/WsZfHcEQwLGPWyEbZyXitqlRPYCvhpS27wuKeuFKfme7BTUymzQVAUsMKYxmzTfv5Q0HWCdk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tIG8VuUr; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tIG8VuUr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 24D21C4CEF7; Sat, 17 Jan 2026 19:07:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768676845; bh=wvP+WP9tHXE//mbhVEIHbRHuOfsqiDs/WYK3kZyFGuU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=tIG8VuUryD78YJ3VnpohYAKeGUKqoWHDuaelEhtC11pFPOIBsUXxZF9UIFWCpeG3e ht3ZCvK4QVkUOth141Yr30jE5Vv4SQyVbx8VksHMxXhSOY2gL0lkpJgmL7cy5MQQ0q hraHy0U77gli6SR12Hf2YyXUT6A3g80DFgoYwS3e3KWw2FGBQ1imRYSxNZ8CXM28V2 w6nw3lDZ/xQoYcD1Bw4YgbPxoWZe2yA4wNIkKp7zRVRCKEveNYFDHkn9AwGGuPG2e+ QW6HgDwiO28iVG+tLa4UgKA0Kvo5Bqjbm2PbgHWL1+S1ATuY2o5hqmvWHbuc4QyRaA XfdXgv6eNgmEw== Date: Sat, 17 Jan 2026 11:07:24 -0800 From: Kees Cook To: David Laight Cc: Bill Wendling , "Gustavo A. R. Silva" , Nathan Chancellor , Nick Desaulniers , Justin Stitt , Miguel Ojeda , Peter Zijlstra , Andrew Morton , Heiko Carstens , Marc Herbert , Uros Bizjak , Tejun Heo , Jeff Xu , Michal =?iso-8859-1?Q?Koutn=FD?= , Shakeel Butt , Thomas =?iso-8859-1?Q?Wei=DFschuh?= , John Stultz , Christian Brauner , Randy Dunlap , Brian Gerst , Masahiro Yamada , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, llvm@lists.linux.dev, Nicolas Schier , Tamir Duberstein , Steven Rostedt , "Jason A. Donenfeld" , "H. Peter Anvin" , Naman Jain , Simon Horman , Jakub Kicinski , Paolo Abeni , Ingo Molnar , Thomas Gleixner , Douglas Anderson , linux-kbuild@vger.kernel.org Subject: Re: [PATCH v4 1/2] Compiler Attributes: Add __counted_by_ptr macro Message-ID: <202601171106.90E508A9D4@keescook> References: <20260114193716.1740684-1-morbo@google.com> <20260116005838.2419118-1-morbo@google.com> <20260116095318.46a149fb@pumpkin> Precedence: bulk X-Mailing-List: llvm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260116095318.46a149fb@pumpkin> On Fri, Jan 16, 2026 at 09:53:18AM +0000, David Laight wrote: > On Fri, 16 Jan 2026 00:57:57 +0000 > Bill Wendling wrote: > > > Introduce __counted_by_ptr(), which works like __counted_by(), but for > > pointer struct members. > > > > struct foo { > > int a, b, c; > > char *buffer __counted_by_ptr(bytes); > > short nr_bars; > > struct bar *bars __counted_by_ptr(nr_bars); > > size_t bytes; > > }; > > > > Because "counted_by" can only be applied to pointer members in very > > recent compiler versions, its application ends up needing to be distinct > > from flexibe array "counted_by" annotations, hence a separate macro. > ... > > diff --git a/Makefile b/Makefile > > index 9d38125263fb..6b029f694bc2 100644 > > --- a/Makefile > > +++ b/Makefile > > @@ -952,6 +952,12 @@ KBUILD_CFLAGS += $(CC_AUTO_VAR_INIT_ZERO_ENABLER) > > endif > > endif > > > > +ifdef CONFIG_CC_IS_CLANG > > +ifdef CONFIG_CC_HAS_COUNTED_BY_PTR > > +KBUILD_CFLAGS += -fexperimental-late-parse-attributes > > +endif > > +endif > > Will that still be needed for clang 22? AFAIK, yes. AIUI, this flag will remain while -fbounds-safety continues to be upstreamed into LLVM. > Looks a bit like a temporary flag to avoid regressions. > Probably ought to at least have a comment that it won't be needed > by some future clang version so that it gets tidied up. Once it's no longer needed, yes, I will want it removed from the Makefile. -- Kees Cook