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

From: Alexei Starovoitov

Date: Thu Nov 26 2026 - 19:18:43 EST


On Thu, Nov 26, 2026 at 09:30 AM Andy Lutomirski <luto@xxxxxxxxxx> wrote:
> Okay. So maybe there should be a nice patch set to *fix* it.

In a perfect world, yes, it would be nice to fix, but no one stumbled
on it since the probe_read_kernel appeared in 2009, so it's worth
fixing only if it doesn't kill tracing as a feature.
Kernel observability is a mandatory feature.
Looking at 3 options:

> 1. Walking a little list or table to validate the address (which may require some sort of synchronization and obviously needs to be NMI-safe -- for systems that use TLB-flush IPIs, blocking interrupts could probably do most of the hard work, and otherwise a little flag set while a read is in progress that can block the change of an address from safe to unsafe would do it.

walk and the synchronization makes it unusable due to NMI,
but we we can give uncached ioremap() a different range vs vmalloc()
then it might be practical with a single range check.

> 2. Allocate a PKS key for the purpose and use it. (Only works on systems that have PKS.)

My research showed that the effort to get PKS into the kernel stalled years ago,
and it's intel only feature.

> 3. Use an entire mm for the purpose and treat it as a user access. This is probably the cleanest solution but it will be slooooooooow.

You mean like use_temporary_mm() with direct cr3 writes ?
If every read needs mm switch that might expose intel HW bugs.
I remember div bug and I bet there are more lurking in the hw.
I'd rather not push the hw limits.

As a summary I don't see a practical improvement for probe_read_kernel.
Maybe there is an option 4 and 5.

The main point that it's orgonal to this patchset.

btw I'm planning to explore PKU for other bpf needs
if writes to PKRU register are fast enough.