linux-stable/arch/s390/net
Ilya Leoshkevich 6decfb1b5a s390/bpf: Pass through tail call counter in trampolines
[ Upstream commit a192103a11 ]

s390x eBPF programs use the following extension to the s390x calling
convention: tail call counter is passed on stack at offset
STK_OFF_TCCNT, which callees otherwise use as scratch space.

Currently trampoline does not respect this and clobbers tail call
counter. This breaks enforcing tail call limits in eBPF programs, which
have trampolines attached to them.

Fix by forwarding a copy of the tail call counter to the original eBPF
program in the trampoline (for fexit), and by restoring it at the end
of the trampoline (for fentry).

Fixes: 528eb2cb87 ("s390/bpf: Implement arch_prepare_bpf_trampoline()")
Reported-by: Leon Hwang <hffilwlqm@gmail.com>
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20230906004448.111674-1-iii@linux.ibm.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-09-19 12:30:20 +02:00
..
bpf_jit.h
bpf_jit_comp.c s390/bpf: Pass through tail call counter in trampolines 2023-09-19 12:30:20 +02:00
Makefile
pnet.c