Le 02/12/2026 à 03:39, James Houghton a écrit :
__copy_{from,to}_user() and __copy_{from,to}_user_inatomic() don't call
access_ok(): they rely on the caller having called it earlier. That
earlier check may have happened in a different context, e.g. KVM checks
a guest's memory slots when they are set up, and then accesses them
through __copy_{from,to}_user() from whichever task happens to run the
vCPU, or to tear down the VM. So the check in access_ok() doesn't cover
these accesses.
Add uaccess_should_fail(), which combines the NULL current->mm check
with the existing should_fail_usercopy() fault injection, and use it in
place of should_fail_usercopy() in __copy_{from,to}_user() and
__copy_to_user_inatomic(). __copy_from_user_inatomic() never called
should_fail_usercopy(), so only add the NULL mm check there, rather than
start injecting failures that some of its callers don't expect, e.g.
__wp_page_copy_user() warns if the copy fails twice.
Instead, shouldn't we try to get rid of this unchecked user accesses
completely ? Linus started already to try and get rid of __get_user()
and __put_user() completely. Shouldn't we continue in that direction ?
Christophe