[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <202601171103.EF310A7@keescook>
Date: Sat, 17 Jan 2026 11:05:34 -0800
From: Kees Cook <kees@...nel.org>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Miguel Ojeda <miguel.ojeda.sandonis@...il.com>,
Bill Wendling <morbo@...gle.com>, linux-kernel@...r.kernel.org,
Qing Zhao <qing.zhao@...cle.com>,
"Gustavo A. R. Silva" <gustavoars@...nel.org>,
Nathan Chancellor <nathan@...nel.org>,
Nick Desaulniers <nick.desaulniers+lkml@...il.com>,
Justin Stitt <justinstitt@...gle.com>,
Miguel Ojeda <ojeda@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Heiko Carstens <hca@...ux.ibm.com>,
Marc Herbert <Marc.Herbert@...ux.intel.com>,
Uros Bizjak <ubizjak@...il.com>, Tejun Heo <tj@...nel.org>,
Jeff Xu <jeffxu@...omium.org>,
Michal Koutný <mkoutny@...e.com>,
Shakeel Butt <shakeel.butt@...ux.dev>,
Thomas Weißschuh <thomas.weissschuh@...utronix.de>,
John Stultz <jstultz@...gle.com>,
Christian Brauner <brauner@...nel.org>,
Randy Dunlap <rdunlap@...radead.org>,
Brian Gerst <brgerst@...il.com>,
Masahiro Yamada <masahiroy@...nel.org>,
linux-hardening@...r.kernel.org, llvm@...ts.linux.dev,
Jan Hendrik Farr <kernel@...rr.cc>
Subject: Re: [PATCH v2 1/2] Compiler Attributes: Add __counted_by_ptr macro
On Fri, Jan 16, 2026 at 09:35:16AM +0100, Peter Zijlstra wrote:
> On Fri, Nov 21, 2025 at 10:47:45PM +0100, Miguel Ojeda wrote:
> > On Fri, Nov 21, 2025 at 8:55 PM Bill Wendling <morbo@...gle.com> wrote:
> > >
> > > +/*
> > > + * Optional: only supported since clang >= 21
> > > + *
> > > + * clang: https://github.com/llvm/llvm-project/pull/137250
> > > + */
> > > +#ifdef CONFIG_CC_HAS_COUNTED_BY_FOR_POINTER
> > > +#define __counted_by_ptr(member) __attribute__((__counted_by__(member)))
> > > +#else
> > > +#define __counted_by_ptr(member)
> > > +#endif
> >
> > I guess there is a reason for this name, but it sounds to me a bit
> > like the thing between parenthesis is a pointer, i.e. that perhaps it
> > is the pointee that one that counts.
> >
> > Hmm... what about `__ptr_counted_by`?
>
> Kees promised to drop this attribute once GCC-16 releases by basically
> doing 's/__counted_by_ptr/__counted_by/' and unifying things again.
Yeah, this will effectively raise "counted_by" support to GCC 16 (from
15) and to Clang 22 (from 20). I'd still prefer to keep the earlier
support, but we'll see how it goes.
-Kees
--
Kees Cook
Powered by blists - more mailing lists