Re: [PATCH v2 11/12] uaccess: Refuse and warn on masked user accesses without an mm

From: James Houghton

Date: Wed Dec 02 2026 - 11:54:41 EST


On Wed, Dec 2, 2026 at 7:36 AM David Laight
<david.laight.linux@xxxxxxxxx> wrote:
>
> On Wed, 2 Dec 2026 02:39:18 +0000
> James Houghton <jthoughton@xxxxxxxxxx> wrote:
>
> > With masked user access (x86-64 and powerpc), mask_user_address() and
> > masked_user_*_access_begin() take the place of access_ok(), so the
> > NULL current->mm check that the previous patch added to access_ok()
> > doesn't cover these paths.
>
> Ugg...
> This adds a conditional branch to hot code paths that are pretty much
> carefully arranged to not contain one.
>
> The WARN_ON_ONCE() also add inline bloat (more so on some architectures
> than others).
> (The same is true for the previous patch.)
>
> Adding tests to the unusual call paths is one thing, but not to the
> normal paths which always run in the context of a system call for a
> normal user process.

Thanks David, yeah I think I'll put the checks back into the copying
routines and leave them out of access_ok() and the masking routines.
Christophe and Dave had similar concerns[1].

The WARN_ON_ONCE() bloat is real but doesn't seem that high; I
measured it[2]. Let me know if those results concern you.

Thanks for the feedback!

[1] https://lore.kernel.org/kvm/b7a920dc-a150-468b-bee1-1c2c22dd75c5@xxxxxxxxx/
[2] https://lore.kernel.org/kvm/CADrL8HWVE7Zj+kFEZbrf16nmmdOONWpobZ7L0KBiD4-AcysFkw@xxxxxxxxxxxxxx/