Re: [PATCH v2 00/12] uaccess: Refuse and warn on user accesses when current->mm is NULL
From: David Laight
Date: Wed Dec 02 2026 - 12:42:11 EST
On Wed, 2 Dec 2026 07:24:13 -0800
Dave Hansen <dave.hansen@xxxxxxxxx> wrote:
> On 12/2/26 07:04, Christophe Leroy (CS GROUP) wrote:
> > Also about the masked user access path, the principle of that path is to
> > be branch-less, the whole purpose was the remove the test/branch from
> > access_ok(). With your new check it is not anymore branch-less
>
> Branches themselves are OK.
Sort of - unless they get mispredicted.
They then cost ~40 cycles on my zen-5, and I suspect that is typical.
Even without the spectre v1 issues the 'masked' variants are so much better.
Oh, and then there is the cost of reading current->mm to consider.
That might be a cache-line miss.
> The problem branches are around access
> checks because they potentially allow transient execution paths to skip
> the checking.
>
> In this case, the new check forces a return before any accesses happen
> or any bounds checks are done. If the new check was incorrectly
> speculated, we'd just have transient execution doing what the
> *architectural* path is allowed to do today.
>
> I _think_ that's OK, at least from a spectre v1 perspective. But it
> could definitely use some more eyeballs on it.
I think you'd need a user-controllable address that passes the access_ok()
check but then reads from somewhere the user isn't allowed to access.
Unlikely to be possible.
David
>
> I do agree with you about the code size concerns.
>