Re: [PATCH v2 00/12] uaccess: Refuse and warn on user accesses when current->mm is NULL

From: Dave Hansen

Date: Wed Dec 02 2026 - 13:07:35 EST


On 12/2/26 09:41, David Laight wrote:
> 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.

My point is that misprediction alone not the problem. You have to pair
misprediction with an attacker-influenced access. You can put all the
branches in the world in to a path, as long as the attacker's actual
access is neutered.

Look at _inline_copy_from_user(). It's full of branches. But, it's safe
because all of the paths to raw_copy_from_user() (the potentially
exploitable access) have mitigations.

All of the paths that lead to "goto fail" are safe because they skip
raw_copy_from_user().

The can_do_masked_user_access() path is safe because it masks the
address (mitigation #1). The else{} side of that check is also safe. It
has one path leading to "goto fail" which doesn't do
raw_copy_from_user(). The other path has a speculation barrier in it,
which makes *that* path safe from bad speculation too (mitigation #2).