From: Alejandro Colomar <alx@kernel.org>
To: Kees Cook <kees@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Christopher Bazley <chris.bazley.wg14@gmail.com>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Marco Elver <elver@google.com>, Michal Hocko <mhocko@suse.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Al Viro <viro@zeniv.linux.org.uk>,
Alexander Potapenko <glider@google.com>,
Dmitry Vyukov <dvyukov@google.com>, Jann Horn <jannh@google.com>,
"Maciej W. Rozycki" <macro@orcam.me.uk>
Subject: Re: [PATCH v5 4/4] mm: Use ARRAY_END() instead of open-coding it
Date: Tue, 23 Dec 2025 02:07:26 +0100 [thread overview]
Message-ID: <aUnpiDyge6VdsnpB@devuan> (raw)
In-Reply-To: <202512221517.E1B039879E@keescook>
[-- Attachment #1: Type: text/plain, Size: 1335 bytes --]
Hi Kees,
On Mon, Dec 22, 2025 at 03:21:21PM -0800, Kees Cook wrote:
> > Now that the first patch set has been merged, I'm working on a second
> > round.
> >
> > I've written a semantic patch:
> >
> > $ cat src/spatch/array_end.sp
> > @@
> > expression a;
> > @@
> >
> > - a + ARRAY_SIZE(a)
> > + ARRAY_END(a)
> >
> > @@
> > expression a;
> > @@
> >
> > - ARRAY_SIZE(a) + a
> > + ARRAY_END(a)
>
> I think you can add parens which will be silently removed but gain you
> the commutative behavior:
Ahhh, thanks! I was wondering how I could get commutative behavior.
> @@
> expression a;
> @@
>
> - (ARRAY_SIZE(a) + a)
> + ARRAY_END(a)
>
> I *think* that'll cover "a + ARRAY_SIZE(a)" too.
Yup, it works. :)
> Anyway, looks good!
Thanks!
> You could send it directly to Linus at the end of
> the next rc1, and he may take it.
I'll send a draft before that, just for you to review the actual patch.
> If not, you'll want to split the patch
> up and send to subsystems after ARRAY_END is in Linus's tree. I use this
> tool to split a large single patch into per-subsystem patches:
> https://github.com/kees/kernel-tools/blob/trunk/split-on-maintainer
Okay. I can do both, anyway.
Have a lovely night!
Alex
--
<https://www.alejandro-colomar.es>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2025-12-23 1:07 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1758806023.git.alx@kernel.org>
2025-11-09 18:06 ` [PATCH v3 0/4] Add ARRAY_END(), and use it to fix off-by-one bugs Alejandro Colomar
2025-11-09 18:06 ` [PATCH v3 1/4] array_size.h: Add ARRAY_END() Alejandro Colomar
2025-11-09 19:05 ` Maciej W. Rozycki
2025-11-09 19:18 ` Alejandro Colomar
2025-11-09 18:06 ` [PATCH v3 2/4] mm: Fix benign off-by-one bugs Alejandro Colomar
2025-11-09 18:07 ` [PATCH v3 3/4] kernel: Fix off-by-one benign bugs Alejandro Colomar
2025-11-09 18:07 ` [PATCH v3 4/4] mm: Use ARRAY_END() instead of open-coding it Alejandro Colomar
2025-11-09 19:45 ` [PATCH v4 0/4] Add ARRAY_END(), and use it to fix off-by-one bugs Alejandro Colomar
2025-11-09 19:45 ` [PATCH v4 1/4] array_size.h: Add ARRAY_END() Alejandro Colomar
2025-11-09 19:45 ` [PATCH v4 2/4] mm: Fix benign off-by-one bugs Alejandro Colomar
2025-11-09 19:45 ` [PATCH v4 3/4] kernel: Fix off-by-one benign bugs Alejandro Colomar
2025-11-09 19:45 ` [PATCH v4 4/4] mm: Use ARRAY_END() instead of open-coding it Alejandro Colomar
2025-12-10 22:46 ` [PATCH v5 0/4] Add ARRAY_END(), and use it to fix off-by-one bugs Alejandro Colomar
2025-12-10 22:46 ` [PATCH v5 1/4] array_size.h: Add ARRAY_END() Alejandro Colomar
2025-12-10 22:46 ` [PATCH v5 2/4] mm: Fix benign off-by-one bugs Alejandro Colomar
2025-12-10 22:46 ` [PATCH v5 3/4] kernel: Fix off-by-one benign bugs Alejandro Colomar
2025-12-10 22:46 ` [PATCH v5 4/4] mm: Use ARRAY_END() instead of open-coding it Alejandro Colomar
2025-12-10 23:18 ` Kees Cook
2025-12-11 0:21 ` Alejandro Colomar
2025-12-11 1:37 ` Kees Cook
2025-12-21 14:07 ` Alejandro Colomar
2025-12-22 23:21 ` Kees Cook
2025-12-23 1:07 ` Alejandro Colomar [this message]
2025-12-11 10:43 ` [PATCH v6 0/4] Add ARRAY_END(), and use it to fix off-by-one bugs Alejandro Colomar
2025-12-11 10:43 ` [PATCH v6 1/4] array_size.h: Add ARRAY_END() Alejandro Colomar
2025-12-11 10:43 ` [PATCH v6 2/4] mm: Fix benign off-by-one bugs Alejandro Colomar
2025-12-11 10:44 ` [PATCH v6 3/4] kernel: Fix off-by-one benign bugs Alejandro Colomar
2025-12-11 10:44 ` [PATCH v6 4/4] mm: Use ARRAY_END() instead of open-coding it Alejandro Colomar
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=aUnpiDyge6VdsnpB@devuan \
--to=alx@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=chris.bazley.wg14@gmail.com \
--cc=dvyukov@google.com \
--cc=elver@google.com \
--cc=glider@google.com \
--cc=jannh@google.com \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux@rasmusvillemoes.dk \
--cc=macro@orcam.me.uk \
--cc=mhocko@suse.com \
--cc=torvalds@linux-foundation.org \
--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