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

From: Kumar Kartikeya Dwivedi

Date: Sun Nov 22 2026 - 17:00:15 EST


Hello, Boris.

On Sun, 22 Nov 2026 at 21:09, Borislav Petkov <bp@xxxxxxxxx> wrote:
>
> On Fri, Oct 09, 2026 at 05:23:13PM +0200, Kumar Kartikeya Dwivedi wrote:
> > The advantage is losing significant amount of code size in JITed programs and
> > the associated runtime overhead (you can see the numbers in the cover letter).
> >
> > Do note that we can make it more generic, we can follow up and optimize
> > copy_from_kernel_nofault() with cpu_feature_enabled(X86_FEATURE_SMAP) as well.
> > But I didn't want to go there just yet. I am happy to work on a follow up if so
> > desired.
>
> So we basically disable SMAP around bpf programs when they are about to
> accesss potentially stale memory and the only line of defense is for
> is_bpf_text_address() to really DTRT.
>
> And once we open the floodgates here, I'm sure you bpf folks will find another
> creative way to flip the kernel on its head.
>
> And all that just to save some bytes.
>
> Sorry, this is simply not worth the risk from where I am standing.

But wouldn't this be strictly contained to BPF programs? I am also
fine putting this behavior behind a CONFIG_BPF_SYSCALL guard. The
kernel will panic in this path otherwise. We just want it to handle
the exception when the fault comes from BPF.

So I am not sure I see how this risks making things worse for anyone
else. It's not about saving some bytes, if you look at the cover
letter, we reduce significant amount of code and associated overhead
from programs running in hot paths.

>
> --
> Regards/Gruss,
> Boris.
>
> https://people.kernel.org/tglx/notes-about-netiquette