From: Peter Zijlstra <peterz@infradead.org>
To: Kees Cook <kees@kernel.org>
Cc: "Miguel Ojeda" <ojeda@kernel.org>,
"Nathan Chancellor" <nathan@kernel.org>,
"Nick Desaulniers" <nick.desaulniers+lkml@gmail.com>,
"Bill Wendling" <morbo@google.com>,
"Justin Stitt" <justinstitt@google.com>,
"Marco Elver" <elver@google.com>,
"Przemek Kitszel" <przemyslaw.kitszel@intel.com>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Masahiro Yamada" <masahiroy@kernel.org>,
"Christophe Leroy" <christophe.leroy@csgroup.eu>,
"Johannes Weiner" <hannes@cmpxchg.org>,
llvm@lists.linux.dev, "Al Viro" <viro@zeniv.linux.org.uk>,
"Arnd Bergmann" <arnd@arndb.de>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Christian Brauner" <brauner@kernel.org>,
"Jan Kara" <jack@suse.cz>,
"Nicolas Schier" <nicolas.schier@linux.dev>,
"Shuah Khan" <shuah@kernel.org>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
"Thomas Weißschuh" <thomas.weissschuh@linutronix.de>,
"Tamir Duberstein" <tamird@gmail.com>,
"Michael Kelley" <mhklinux@outlook.com>,
"kernel test robot" <lkp@intel.com>,
"Heiko Carstens" <hca@linux.ibm.com>,
"Uros Bizjak" <ubizjak@gmail.com>,
"Jan Hendrik Farr" <kernel@jfarr.cc>,
"Yafang Shao" <laoar.shao@gmail.com>,
"Marc Herbert" <Marc.Herbert@linux.intel.com>,
"Christopher Ferris" <cferris@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Alexander Lobakin" <aleksander.lobakin@intel.com>,
"Paolo Abeni" <pabeni@redhat.com>, "Tejun Heo" <tj@kernel.org>,
"Jeff Xu" <jeffxu@chromium.org>,
"Michal Koutný" <mkoutny@suse.com>,
"Shakeel Butt" <shakeel.butt@linux.dev>,
"Randy Dunlap" <rdunlap@infradead.org>,
"Brian Gerst" <brgerst@gmail.com>,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-kbuild@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-hardening@vger.kernel.org
Subject: Re: [PATCH 1/3] compiler_types: Introduce __counted_by_ptr()
Date: Wed, 22 Oct 2025 10:20:25 +0200 [thread overview]
Message-ID: <20251022082025.GK4067720@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <202510211210.84D670D1C@keescook>
On Tue, Oct 21, 2025 at 12:24:05PM -0700, Kees Cook wrote:
> On Tue, Oct 21, 2025 at 11:54:47AM +0200, Peter Zijlstra wrote:
> > So why do we need both __counted_by_ptr() and this __sized_by(), won't
> > one be good enough?
>
> I remain extraordinarily frustrated that counted_by can't be used with
> "void *". I hit a brick wall on this, though, and don't know how to
> convince either GCC or Clang devs to fix it. It's so obviously correct
> to me: "void *" uses a 1 byte iterator for arithmetic... so asking how
> big a given allocation is should be byte sized!
Right, at least for gnu11 language variants this really should work. I
mean, disallow the usage for c11 if you're pedantic but for crying out
loud, have the GNU extensions be consistent and all that.
Feel free to use my feedback if it would help.
> Let me take another stab at it...
Thanks!
> As for avoiding __counted_by_ptr(), we could just raise the minimum
> Clang and GCC versions to require this, but that means dropping existing
> coverage (e.g GCC 15 supports only flexible array counted_by).
>
> Maybe we could do a global __counted_by_ptr -> __counted_by replacement
> once GCC 16 is released?
That sounds like a plan! :-)
next prev parent reply other threads:[~2025-10-22 8:20 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-20 22:01 [PATCH 0/3] compiler_types: Introduce __counted_by_ptr() Kees Cook
2025-10-20 22:01 ` [PATCH 1/3] " Kees Cook
2025-10-20 22:34 ` Marco Elver
2025-10-20 22:53 ` Bill Wendling
2025-10-21 9:59 ` Peter Zijlstra
2025-10-21 9:54 ` Peter Zijlstra
2025-10-21 19:24 ` Kees Cook
2025-10-22 8:20 ` Peter Zijlstra [this message]
2025-10-23 0:47 ` Kees Cook
2025-10-23 8:01 ` Peter Zijlstra
2025-10-23 13:45 ` Kees Cook
2025-10-20 22:01 ` [PATCH 2/3] lkdtm/bugs: Add __counted_by_ptr() test PTR_BOUNDS Kees Cook
2025-10-20 22:01 ` [PATCH 3/3] coredump: Use __counted_by_ptr for struct core_name::corename Kees Cook
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251022082025.GK4067720@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=Marc.Herbert@linux.intel.com \
--cc=akpm@linux-foundation.org \
--cc=aleksander.lobakin@intel.com \
--cc=arnd@arndb.de \
--cc=brauner@kernel.org \
--cc=brgerst@gmail.com \
--cc=cferris@google.com \
--cc=christophe.leroy@csgroup.eu \
--cc=elver@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=gustavoars@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=hca@linux.ibm.com \
--cc=jack@suse.cz \
--cc=jeffxu@chromium.org \
--cc=justinstitt@google.com \
--cc=kees@kernel.org \
--cc=kernel@jfarr.cc \
--cc=kuba@kernel.org \
--cc=laoar.shao@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=lkp@intel.com \
--cc=llvm@lists.linux.dev \
--cc=masahiroy@kernel.org \
--cc=mhklinux@outlook.com \
--cc=mkoutny@suse.com \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=nick.desaulniers+lkml@gmail.com \
--cc=nicolas.schier@linux.dev \
--cc=ojeda@kernel.org \
--cc=pabeni@redhat.com \
--cc=przemyslaw.kitszel@intel.com \
--cc=rdunlap@infradead.org \
--cc=shakeel.butt@linux.dev \
--cc=shuah@kernel.org \
--cc=tamird@gmail.com \
--cc=thomas.weissschuh@linutronix.de \
--cc=tj@kernel.org \
--cc=ubizjak@gmail.com \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox