Re: [PATCH v2 11/12] uaccess: Refuse and warn on masked user accesses without an mm
From: David Laight
Date: Wed Dec 02 2026 - 12:55:40 EST
On Wed, 2 Dec 2026 11:53:43 -0500
James Houghton <jthoughton@xxxxxxxxxx> wrote:
> 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.
Try one of the architectures where it ends up being a real call.
IIRC x86 manages to use an undefined instruction and then do all
the work out of line in the trap handler.
The issue with a real call is that it reduces the number of registers
the compiler has for the enclosing function.
David
>
> 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/