Re: [PATCH bpf-next v1 1/3] x86/mm: Resolve BPF exception fixups for user address faults under SMAP

From: Alexei Starovoitov

Date: Tue Nov 24 2026 - 15:17:19 EST


On Tue, Nov 24, 2026 at 07:25 AM Dave Hansen <dave.hansen@xxxxxxxxx> wrote:
> On 11/23/26 09:23, Kumar Kartikeya Dwivedi wrote:
>> It would be equivalent of doing copy_from_kernel_nofault() in the
>> normal kernel.
>
> ... and running afoul a userspace address. So, no, it's not equivalent.
> These accesses are more wild than anything else we have in the kernel.

copy_from_kernel_nofault() runs into user addresses too.
sysrq-t does it for every idle kworker in print_worker_info():

copy_from_kernel_nofault(&pwq, &worker->current_pwq, sizeof(pwq));
copy_from_kernel_nofault(&wq, &pwq->wq, sizeof(wq));

An idle worker has current_pwq == NULL, so the second call gets address 8.
That's the same walk as sk->sk_socket->file: no locks, no NULL check.

The set of addresses is the same. The difference is who refuses a bad one.
"CPU" is a fault and a fixup via extable:

user, guard, unmapped
vsyscall page non-canonical kernel
-------------------------- ------------- ------------- --------
copy_from_kernel_nofault() compare compare CPU
PROBE_MEM today compare CPU CPU
PROBE_MEM, patch 2, SMAP CPU CPU CPU

Every cell ends the same way: no data and no oops.
The series changes one cell.

> Do we at least require that these super specialized programs have the
> bpf_prog_info->gpl_compatible bit set?

Yes. check_ptr_to_btf_access() rejects a load from a kernel struct in a
non-GPL prog:
"Cannot access kernel 'struct sock' from non-GPL compatible program"
The check right above it wants CAP_PERFMON.
It's the same as bpf_probe_read_kernel(), which is gpl_only.