BPF List
 help / color / mirror / Atom feed
* Please backport 7a0855e73757 ("bpf: Disallow interpreter fallback for BPF_ADDR_PERCPU insn") to 6.18.y and 6.12.y
@ 2026-11-25  8:56 Guillaume Laporte
  2026-11-25 13:43 ` Leon Hwang
  0 siblings, 1 reply; 2+ messages in thread
From: Guillaume Laporte @ 2026-11-25  8:56 UTC (permalink / raw)
  To: stable@vger.kernel.org, leon.hwang@linux.dev
  Cc: yangtiezhu@loongson.cn, Alexei Starovoitov, daniel@iogearbox.net,
	bpf@vger.kernel.org, linux@roblab.la

Dear maintainers,

Could you please consider backporting the following commits to 6.18.y
and 6.12.y:

  9a6df65d5c6a ("bpf: Introduce jit_required flag and remove bpf_prog_has_kfunc_call()")
  f1c27922576e ("bpf: Reject programs with inlined helpers if JIT is not available")
  7a0855e73757 ("bpf: Disallow interpreter fallback for BPF_ADDR_PERCPU insn")

All three were backported to 7.2.6, but not to the 6.18.y and 6.12.y
trees, which seem to be the only affected longterm trees: if I'm not
mistaken, the issue was introduced in 6.10 by 7bdbf7446305 ("bpf: add
special internal-only MOV instruction to resolve per-CPU addrs").

Without these commits, on kernels built without
CONFIG_BPF_JIT_ALWAYS_ON, a program that looks up a per-CPU map can
crash the kernel when its JIT compilation fails, for instance because
of constant blinding with net.core.bpf_jit_harden=2.

As far as I understand, the verifier inlines these lookups with the
internal BPF_ADDR_PERCPU instruction, which only the JIT implements.
When the JIT compilation fails, the program falls back to the
interpreter, which does not handle this instruction: the register
keeps a per-CPU offset instead of an address, and the kernel oopses
in ___bpf_prog_run() when dereferencing it. Depending on the context
the program runs in, this results in an oops or a panic.

This was reported on the bpf list with a reproducer [1]. We have hit
this crash on Debian 13 systems, and the reproducer's program still
crashes 6.12.119 and 6.18.65 built with Debian's config.

The three commits prevent this issue and some closely related ones:
- 9a6df65d5c6a adds a jit_required flag, making it possible to
  reject a program at load time when its JIT compilation fails;
- 7a0855e73757 sets it when the verifier emits BPF_ADDR_PERCPU, which
  fixes the crash described above;
- f1c27922576e sets it for programs calling helpers that some JITs
  inline, which the interpreter cannot run either.

Unfortunately, the commits do not apply cleanly to these trees, as
they modify kernel/bpf/fixups.c, which only exists since 7.1. Leon,
thank you for fixing this upstream. In July you mentioned that the fix
should be backported to 6.12 along with Tiezhu's jit_required series
[2]. Would you have time to prepare the backports for 6.18.y and
6.12.y? We would be glad to test them with the reproducer and report
back.

Thank you for your help,

Guillaume Laporte

[1] https://lore.kernel.org/bpf/MR1P264MB331494502C9D13D8A9EAFB99B7E82@MR1P264MB3314.FRAP264.PROD.OUTLOOK.COM/
[2] https://lore.kernel.org/bpf/b76ade17-44cb-4e60-97fc-41ba55258691@linux.dev/

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Please backport 7a0855e73757 ("bpf: Disallow interpreter fallback for BPF_ADDR_PERCPU insn") to 6.18.y and 6.12.y
  2026-11-25  8:56 Please backport 7a0855e73757 ("bpf: Disallow interpreter fallback for BPF_ADDR_PERCPU insn") to 6.18.y and 6.12.y Guillaume Laporte
@ 2026-11-25 13:43 ` Leon Hwang
  0 siblings, 0 replies; 2+ messages in thread
From: Leon Hwang @ 2026-11-25 13:43 UTC (permalink / raw)
  To: Guillaume Laporte, stable@vger.kernel.org, Vincent Thiberville
  Cc: yangtiezhu@loongson.cn, Alexei Starovoitov, daniel@iogearbox.net,
	bpf@vger.kernel.org, linux@roblab.la

On 2026/11/25 16:56, Guillaume Laporte wrote:
> Dear maintainers,
> 
> Could you please consider backporting the following commits to 6.18.y
> and 6.12.y:
> 
>   9a6df65d5c6a ("bpf: Introduce jit_required flag and remove bpf_prog_has_kfunc_call()")
>   f1c27922576e ("bpf: Reject programs with inlined helpers if JIT is not available")
>   7a0855e73757 ("bpf: Disallow interpreter fallback for BPF_ADDR_PERCPU insn")

34746b5a84ec ("bpf: Disallow interpreter fallback for arena-related insns")

This commit will also be backported.

> 
> All three were backported to 7.2.6, but not to the 6.18.y and 6.12.y
> trees, which seem to be the only affected longterm trees: if I'm not
> mistaken, the issue was introduced in 6.10 by 7bdbf7446305 ("bpf: add
> special internal-only MOV instruction to resolve per-CPU addrs").
> 

[...]

> 
> Unfortunately, the commits do not apply cleanly to these trees, as
> they modify kernel/bpf/fixups.c, which only exists since 7.1. Leon,
> thank you for fixing this upstream. In July you mentioned that the fix
> should be backported to 6.12 along with Tiezhu's jit_required series
> [2]. Would you have time to prepare the backports for 6.18.y and
> 6.12.y? We would be glad to test them with the reproducer and report
> back.

No worries. I will backport the aforementioned commits in near future,
will cc Vincent and you.

Thanks,
Leon

> 
> Thank you for your help,
> 
> Guillaume Laporte
> 
> [1] https://lore.kernel.org/bpf/MR1P264MB331494502C9D13D8A9EAFB99B7E82@MR1P264MB3314.FRAP264.PROD.OUTLOOK.COM/
> [2] https://lore.kernel.org/bpf/b76ade17-44cb-4e60-97fc-41ba55258691@linux.dev/


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-25 13:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25  8:56 Please backport 7a0855e73757 ("bpf: Disallow interpreter fallback for BPF_ADDR_PERCPU insn") to 6.18.y and 6.12.y Guillaume Laporte
2026-11-25 13:43 ` Leon Hwang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox