Re: [PATCH] x86: Allow user accesses to the base of the guard page

From: Linus Torvalds
Date: Sat Nov 23 2024 - 14:03:10 EST


On Sat, 23 Nov 2024 at 10:48, David Laight <David.Laight@xxxxxxxxxx> wrote:
>
> In that case access_ok(ptr, size) will check that 'ptr + size'
> is a valid user address -

The point of USER_PTR_MAX is that the size never matters and we never
check it. So the "-1" is basically just the minimal size.

And the code does actually depend on the fact that the access has to
start *before* the boundary to work.

Now, we do have that whole "at least PAGE_SIZE of guard page", and so
the 1-byte minimal size doesn't actually matter, but I don't see the
point of the change.

In particular, I don't see when it would matter to do access_ok(ptr,
0) in the first place. Who does that, and why would it make any sense?

Linus