OSDN Git Service

s390/bpf: Pass through tail call counter in trampolines
authorIlya Leoshkevich <iii@linux.ibm.com>
Wed, 6 Sep 2023 00:44:19 +0000 (02:44 +0200)
committerDaniel Borkmann <daniel@iogearbox.net>
Wed, 6 Sep 2023 08:48:14 +0000 (10:48 +0200)
commita192103a11465e9d517975c50f9944dc80e44d61
tree94a2d8986e02e3b5f3c1e3d7ee215fbf71bb38a7
parent6764e767f4af1e35f87f3497e1182d945de37f93
s390/bpf: Pass through tail call counter in trampolines

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: 528eb2cb87bc ("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
arch/s390/net/bpf_jit_comp.c