From: Alexei Starovoitov A valid program with recursion can be rejected with "the call stack of 33 frames is too deep". No unsafe program is accepted, because the path-sensitive run accepts nothing. A pass can check a recursive function on its own, with no frame for each call. The run has each call of a static function in frames. It can run out of frames and get -E2BIG where no pass does. If the last pass had another error at that call, for example a callx with an unknown target, the run takes -E2BIG for the failing path. The budget of the next passes is cut. If the program needs more, it is rejected. Drop such a path. If each pass is out of frames too, the program is still rejected. Now its log has only the last basic block, not the full path. Fixes: a46de5d64e18 ("bpf: Reproduce an error on one path, with no joins") Signed-off-by: Alexei Starovoitov --- kernel/bpf/verifier.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 5bd6fa081f..f0334f782a 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -21970,10 +21970,13 @@ static int do_check(struct bpf_verifier_env *env) err = do_check_block(env, prev_insn_idx); if (env->bug) return -EFAULT; - /* a pass had no error at this insn, possibly with a state that has more values */ + /* + * A pass had no error at this insn, possibly with a state that has more values. + * -E2BIG: a pass possibly does not have these calls in frames. + */ if (err && env->path_sensitive && is_error_of_state(env, err) && (env->cur_state->infeasible || env->cur_state->equations.infeasible || - !bpf_failing_path_may_end_at(env, env->insn_idx))) { + err == -E2BIG || !bpf_failing_path_may_end_at(env, env->insn_idx))) { bpf_free_verifier_state(env, env->cur_state, false); memset(env->cur_state, 0, sizeof(*env->cur_state)); free_pushed_states(env); -- 2.55.0