mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH bpf 0/2] LoongArch: BPF: Fix tail call count handling
@ 2026-06-25  8:32 George Guo
  2026-06-25  8:32 ` [PATCH bpf 1/2] LoongArch: BPF: Fix tail call count pointer offset for arena programs George Guo
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: George Guo @ 2026-06-25  8:32 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Huacai Chen, Tiezhu Yang, Hengqi Chen
  Cc: WANG Xuerui, Martin KaFai Lau, Eduard Zingerman,
	Kumar Kartikeya Dwivedi, Song Liu, Yonghong Song, Jiri Olsa,
	George Guo, bpf, loongarch, linux-kernel

Two independent fixes for the LoongArch BPF JIT's tail call count (TCC)
handling, both found while enabling the arena and tailcall selftests on
LoongArch.

Patch 1 fixes memory corruption / a kernel panic. For an arena program the
extra REG_ARENA slot in the prologue shifts the callee-saved area down by
one word, but BPF_TAIL_CALL_CNT_PTR_STACK_OFF() did not account for it, so
on every tail call or bpf2bpf call the JIT loaded the counter *value* and
dereferenced it as the TCC pointer.

Patch 2 fixes an off-by-one: emit_bpf_tail_call() increments the tail call
count before the NULL-slot check, so jumping through an empty prog_array
slot is charged against MAX_TAIL_CALL_CNT and programs reach the limit one
call early.

Both carry Fixes: tags and Cc: stable. They touch only emit_bpf_tail_call()
and the new offset helper; there is no functional dependency between them.

George Guo (2):
  LoongArch: BPF: Fix tail call count pointer offset for arena programs
  LoongArch: BPF: Don't charge an empty prog_array slot to the tail call
    count

 arch/loongarch/net/bpf_jit.c | 34 +++++++++++++++++++++++++++++-----
 1 file changed, 29 insertions(+), 5 deletions(-)

-- 
2.25.1


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

end of thread, other threads:[~2026-07-06  7:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-25  8:32 [PATCH bpf 0/2] LoongArch: BPF: Fix tail call count handling George Guo
2026-06-25  8:32 ` [PATCH bpf 1/2] LoongArch: BPF: Fix tail call count pointer offset for arena programs George Guo
2026-06-25  8:32 ` [PATCH bpf 2/2] LoongArch: BPF: Don't charge an empty prog_array slot to the tail call count George Guo
2026-06-29  8:55 ` [PATCH bpf v2] LoongArch: BPF: Fix tail call count pointer offset for arena programs George Guo
2026-07-06  7:30   ` Tiezhu Yang

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

all inboxes | Powered by JetHome®