Re: [RFC PATCH 00/10] uaccess: Refuse and warn on user accesses when current->mm is NULL
From: Arnd Bergmann
Date: Tue Nov 24 2026 - 17:02:55 EST
On Tue, Nov 24, 2026, at 22:10, James Houghton wrote:
> On Wed, Oct 28, 2026 at 7:14 PM Arnd Bergmann <arnd@xxxxxxxx> wrote:
>> On Wed, Oct 28, 2026, at 00:17, James Houghton wrote:
> So now in v2, the _nofault() helpers themselves do not check current->mm.
>
> I've uploaded a draft version of v2 here, in case you want to take a look:
> https://github.com/48ca/linux uaccess-v2-wip
I read through this now and it all looks good to me so far.
>> Since in principle every user access should go through both
>> access_ok/mask_user_address and current->mm check at some point,
>> so combining the two as much as possible should help long-term
>> maintainability.
>
> You're right, and v2 has been restructured like this.
>
> - The check is in access_ok() itself: the generic version, plus the
> arm64 and riscv versions. __access_ok() remains a plain range check.
> - The callers of mask_user_address()/masked_user_*_access_begin()
> check current->mm explicitly. There are about a dozen such callers.
> - The unchecked accessors, __copy_{from,to}_user()
> and__copy_{from,to}_user_inatomic() (and arm64's
> copy_from_user_flushcache(), which also relies on an earlier
> access_ok()), keep an explicit check for now. Once their users are
> converted to the checked versions, those checks can be dropped.
Ok, sounds all good. If we get more than handful of mask_user_address()
and masked_user_*_access_begin(), we can always revisit that interface
to make sure the check can't be skipped, but for now this seems
like a good tradeoff.
> Compared to v1, this also covers get_user()/put_user()/clear_user() on
> arm64, powerpc, riscv and the asm-generic architectures, and arch code
> like signal frame setup that uses access_ok() followed by __put_user()
> or unsafe_*(). user_access_begin() no longer needs its own check.
>
> What's still not covered: x86's get_user()/put_user(), which do their
> own range check in asm, a few architecture-specific paths that call
> __access_ok() directly (e.g. on alpha and sparc32), and arch code that
> calls __get_user()/__put_user() without access_ok(), mostly trap
> handlers for user-mode faults. Probably best tackled later.
ok
>> There are probably few enough of these that we could address them
>> by either adding current->mm checks or converting them to use
>> the full versions instead where that is an obvious change like
>> that usb gadget driver.
>
> Sounds good. I'll send a separate series converting the obvious ones,
> starting with the usb gadget driver. I think that will be useful.
> Let's see how far I can get; hopefully I can drop
> __copy_{from,to}_user() completely.
Ok, perfect!
Arnd