]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
bpf, verifier: Correct tail_call_reachable for bpf prog
authorLeon Hwang <hffilwlqm@gmail.com>
Mon, 10 Jun 2024 12:42:23 +0000 (20:42 +0800)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 21 Jun 2024 02:48:29 +0000 (19:48 -0700)
It's confusing to inspect 'prog->aux->tail_call_reachable' with drgn[0],
when bpf prog has tail call but 'tail_call_reachable' is false.

This patch corrects 'tail_call_reachable' when bpf prog has tail call.

Signed-off-by: Leon Hwang <hffilwlqm@gmail.com>
Link: https://lore.kernel.org/r/20240610124224.34673-2-hffilwlqm@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/verifier.c

index dcbbf5f64c5de79eb541d346a72b3b6839565c30..ffe98a788c33d3fbd83c240f27114cff75c90077 100644 (file)
@@ -2982,8 +2982,10 @@ static int check_subprogs(struct bpf_verifier_env *env)
 
                if (code == (BPF_JMP | BPF_CALL) &&
                    insn[i].src_reg == 0 &&
-                   insn[i].imm == BPF_FUNC_tail_call)
+                   insn[i].imm == BPF_FUNC_tail_call) {
                        subprog[cur_subprog].has_tail_call = true;
+                       subprog[cur_subprog].tail_call_reachable = true;
+               }
                if (BPF_CLASS(code) == BPF_LD &&
                    (BPF_MODE(code) == BPF_ABS || BPF_MODE(code) == BPF_IND))
                        subprog[cur_subprog].has_ld_abs = true;