Skip to content

Commit bc3905a

Browse files
iii-iborkmann
authored andcommitted
s390/bpf: Write back tail call counter for BPF_TRAMP_F_CALL_ORIG
The tailcall_bpf2bpf_hierarchy_fentry test hangs on s390. Its call graph is as follows: entry() subprog_tail() trampoline() fentry() the rest of subprog_tail() # via BPF_TRAMP_F_CALL_ORIG return to entry() The problem is that the rest of subprog_tail() increments the tail call counter, but the trampoline discards the incremented value. This results in an astronomically large number of tail calls. Fix by making the trampoline write the incremented tail call counter back. Fixes: 528eb2c ("s390/bpf: Implement arch_prepare_bpf_trampoline()") Signed-off-by: Ilya Leoshkevich <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent c861a6b commit bc3905a

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

arch/s390/net/bpf_jit_comp.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2839,6 +2839,9 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im,
28392839
/* stg %r2,retval_off(%r15) */
28402840
EMIT6_DISP_LH(0xe3000000, 0x0024, REG_2, REG_0, REG_15,
28412841
tjit->retval_off);
2842+
/* mvc tccnt_off(%r15),tail_call_cnt(4,%r15) */
2843+
_EMIT6(0xd203f000 | tjit->tccnt_off,
2844+
0xf000 | offsetof(struct prog_frame, tail_call_cnt));
28422845

28432846
im->ip_after_call = jit->prg_buf + jit->prg;
28442847

0 commit comments

Comments
 (0)