From: Alexei Starovoitov The main pass does not enter the callback of bpf_loop(0, cb). When cb comes from a table of functions, nothing keeps it and it is removed. The inlined loop still has 'call cb'. The call goes to the next function, or the load fails with 'verifier bug: No program to jit'. Leave the call of the helper. It does not look at cb. Signed-off-by: Alexei Starovoitov --- kernel/bpf/fixups.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kernel/bpf/fixups.c b/kernel/bpf/fixups.c index 8d1dd0770711..d1eecb95545f 100644 --- a/kernel/bpf/fixups.c +++ b/kernel/bpf/fixups.c @@ -3610,8 +3610,12 @@ int bpf_optimize_bpf_loop(struct bpf_verifier_env *env) struct bpf_loop_inline_state *inline_state = &env->insn_aux_data[i].loop_inline_state; - /* the callback that takes a stack in arena is not for a call from the program */ + /* + * The callback that takes a stack in arena is not for a call from the program. + * The callback of a loop without iterations is dead code, it goes away. + */ if (is_bpf_loop_call(insn) && inline_state->fit_for_inline && + env->insn_aux_data[subprogs[inline_state->callback_subprogno].start].seen && !subprogs[inline_state->callback_subprogno].arena_stack_entry) { stack_depth_extra = BPF_REG_SIZE * 3 + stack_depth_roundup; err = inline_bpf_loop(env, i, -- 2.55.0