Re: [PATCH v1 0/3] Add ENDOF(), and use it to fix off-by-one bugs

From: Kees Cook
Date: Thu Sep 25 2025 - 21:31:16 EST


On Thu, Sep 25, 2025 at 06:05:25PM -0700, Linus Torvalds wrote:
> On Thu, Sep 25, 2025, 17:00 Kees Cook <kees@xxxxxxxxxx> wrote:
>
> > And it's really ARRAY_BEYOND. ;) I don't really like having APIs that
> > require holding pointers that are actively invalid, either.
>
> That's not an invalid pointer. At all.

Sorry, I mean to say that it points _to_ an invalid location. The
pointer is not valid to dereference, but its _value_ has meaning
(relative to another pointer).

I can have an opinion about the relative safety of holding pointers that
can't be safely dereferenced, though. :) But yes, I've long since lost
the argument that C should avoid these kinds of past-the-end tokens.

-Kees

--
Kees Cook