Skip to content

Commit eada40e

Browse files
iii-iborkmann
authored andcommitted
s390/bpf: Do not write tail call counter into helper and kfunc frames
Only BPF functions make use of the tail call counter; helpers and kfuncs ignore and most likely also clobber it. Writing it into these functions' frames is pointless and misleading, so do not do it. Fixes: dd691e8 ("s390/bpf: Implement bpf_jit_supports_subprog_tailcalls()") Signed-off-by: Ilya Leoshkevich <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 3ec8560 commit eada40e

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

arch/s390/net/bpf_jit_comp.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1790,6 +1790,7 @@ static noinline int bpf_jit_insn(struct bpf_jit *jit, struct bpf_prog *fp,
17901790

17911791
REG_SET_SEEN(BPF_REG_5);
17921792
jit->seen |= SEEN_FUNC;
1793+
17931794
/*
17941795
* Copy the tail call counter to where the callee expects it.
17951796
*
@@ -1800,10 +1801,17 @@ static noinline int bpf_jit_insn(struct bpf_jit *jit, struct bpf_prog *fp,
18001801
* Note 2: We assume that the verifier does not let us call the
18011802
* main program, which clears the tail call counter on entry.
18021803
*/
1803-
/* mvc tail_call_cnt(4,%r15),frame_off+tail_call_cnt(%r15) */
1804-
_EMIT6(0xd203f000 | offsetof(struct prog_frame, tail_call_cnt),
1805-
0xf000 | (jit->frame_off +
1806-
offsetof(struct prog_frame, tail_call_cnt)));
1804+
1805+
if (insn->src_reg == BPF_PSEUDO_CALL)
1806+
/*
1807+
* mvc tail_call_cnt(4,%r15),
1808+
* frame_off+tail_call_cnt(%r15)
1809+
*/
1810+
_EMIT6(0xd203f000 | offsetof(struct prog_frame,
1811+
tail_call_cnt),
1812+
0xf000 | (jit->frame_off +
1813+
offsetof(struct prog_frame,
1814+
tail_call_cnt)));
18071815

18081816
/* Sign-extend the kfunc arguments. */
18091817
if (insn->src_reg == BPF_PSEUDO_KFUNC_CALL) {

0 commit comments

Comments
 (0)