Skip to content

Commit 5f55f21

Browse files
iii-iAlexei Starovoitov
authored andcommitted
s390/bpf: Store backchain even for leaf progs
Currently a crash in a leaf prog (caused by a bug) produces the following call trace: [<000003ff600ebf00>] bpf_prog_6df0139e1fbf2789_fentry+0x20/0x78 [<0000000000000000>] 0x0 This is because leaf progs do not store backchain. Fix by making all progs do it. This is what GCC and Clang-generated code does as well. Now the call trace looks like this: [<000003ff600eb0f2>] bpf_prog_6df0139e1fbf2789_fentry+0x2a/0x80 [<000003ff600ed096>] bpf_trampoline_201863462940+0x96/0xf4 [<000003ff600e3a40>] bpf_prog_05f379658fdd72f2_classifier_0+0x58/0xc0 [<000003ffe0aef070>] bpf_test_run+0x210/0x390 [<000003ffe0af0dc2>] bpf_prog_test_run_skb+0x25a/0x668 [<000003ffe038a90e>] __sys_bpf+0xa46/0xdb0 [<000003ffe038ad0c>] __s390x_sys_bpf+0x44/0x50 [<000003ffe0defea8>] __do_syscall+0x150/0x280 [<000003ffe0e01d5c>] system_call+0x74/0x98 Fixes: 0546231 ("s390/bpf: Add s390x eBPF JIT compiler backend") Signed-off-by: Ilya Leoshkevich <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 4dd372d commit 5f55f21

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

arch/s390/net/bpf_jit_comp.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -605,17 +605,15 @@ static void bpf_jit_prologue(struct bpf_jit *jit, struct bpf_prog *fp,
605605
}
606606
/* Setup stack and backchain */
607607
if (is_first_pass(jit) || (jit->seen & SEEN_STACK)) {
608-
if (is_first_pass(jit) || (jit->seen & SEEN_FUNC))
609-
/* lgr %w1,%r15 (backchain) */
610-
EMIT4(0xb9040000, REG_W1, REG_15);
608+
/* lgr %w1,%r15 (backchain) */
609+
EMIT4(0xb9040000, REG_W1, REG_15);
611610
/* la %bfp,STK_160_UNUSED(%r15) (BPF frame pointer) */
612611
EMIT4_DISP(0x41000000, BPF_REG_FP, REG_15, STK_160_UNUSED);
613612
/* aghi %r15,-STK_OFF */
614613
EMIT4_IMM(0xa70b0000, REG_15, -(STK_OFF + stack_depth));
615-
if (is_first_pass(jit) || (jit->seen & SEEN_FUNC))
616-
/* stg %w1,152(%r15) (backchain) */
617-
EMIT6_DISP_LH(0xe3000000, 0x0024, REG_W1, REG_0,
618-
REG_15, 152);
614+
/* stg %w1,152(%r15) (backchain) */
615+
EMIT6_DISP_LH(0xe3000000, 0x0024, REG_W1, REG_0,
616+
REG_15, 152);
619617
}
620618
}
621619

0 commit comments

Comments
 (0)