Re: [PATCH v1] arm64: Mitigate Spectre v1 in the BPF interpreter

From: Ryan Roberts

Date: Mon Nov 23 2026 - 11:48:29 EST


On 23/11/2026 15:37, Catalin Marinas wrote:
> On Mon, Nov 23, 2026 at 10:49:58AM +0000, Ryan Roberts wrote:
>> On 23/11/2026 04:07, Alexei Starovoitov wrote:
>>> On Sun, Nov 22, 2026 at 12:58 AM Ryan Roberts <ryan.roberts@xxxxxxx> wrote:
>>>> I view this patch as a fix to arm64, not as a fix to BPF. I haven't changed any
>>>> BPF code - I've only removed an out of date comment in BPF code, which assumed
>>>> the code path was for Spectre v4 only. But that's not true since Commit
>>>> dff883d9e93a ("bpf, arm64, powerpc: Change nospec to include v1 barrier").
>>>
>>> Fair enough, but the arm64 part of that comment is stale.
>>> The verifier relies on nospec for v1 since
>>> commit d6f1c85f2253 ("bpf: Fall back to nospec for Spectre v1").
>>>
>>>> arm64 was previously nop'ing barrier_nospec() despite seemingly needing it in
>>>> the same situation as x86. I think this is orthogonal to whether or not the BPF
>>>> interpreter permits speculation attacks in other places?
>>>
>>> Not quite. In the interpreter the barrier sits behind an indirect branch:
>>>
>>> goto *jumptable[insn->code];
>>>
>>> arm64 has no retpoline, and the prog can train this branch.
>>> With a wrong target the CPU skips ST_NOSPEC and runs the next insn.
>>> So the interpreter is still not safe.
>>> Yet you're arguing that you're making bpf interpreter a viable option
>>> on arm64. That's just not fair to users.
>
> [...]
>
>>> Say it in the commit log that you're fixing one tiny issue and leaving
>>> giant security hole in place.
>>> With that I'm no longer nacking it.
>>
>> Happy to fix up the commit log as you suggest.
>
> This patch closes the Spectre v1 hole in the interpreter but, as per
> Alexei's point, we are still left open to Spectre v2, even with CSV2.
> CSV2 only isolates branch prediction between contexts and here the
> predictor could be trained from within the BPF program itself (in
> theory, not sure if this has been demonstrated on arm64 though).
> Training it this way is harder but I wonder whether it's worth patching
> the kernel for v1 or just recommend that people disable unprivileged,
> interpreted BPF (that's Arm's official recommendation anyway). Would we
> give the wrong impression that such configuration is safe?
>
> If Alexei makes the Kconfig change to force JIT always on, I'd be
> inclined to drop this patch.

Works for me.