bpf: print full verifier states on infinite loop detection
authorEduard Zingerman <eddyz87@gmail.com>
Tue, 24 Oct 2023 00:09:17 +0000 (03:09 +0300)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 24 Oct 2023 04:49:32 +0000 (21:49 -0700)
Additional logging in is_state_visited(): if infinite loop is detected
print full verifier state for both current and equivalent states.

Acked-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
Link: https://lore.kernel.org/r/20231024000917.12153-8-eddyz87@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/verifier.c

index f23fbfe82c5989df7cb05a4918d5104f46de01cf..98f9d0f35931f7c6095b8f798d63e4f41dfe4476 100644 (file)
@@ -16928,6 +16928,10 @@ static int is_state_visited(struct bpf_verifier_env *env, int insn_idx)
                            !iter_active_depths_differ(&sl->state, cur)) {
                                verbose_linfo(env, insn_idx, "; ");
                                verbose(env, "infinite loop detected at insn %d\n", insn_idx);
+                               verbose(env, "cur state:");
+                               print_verifier_state(env, cur->frame[cur->curframe], true);
+                               verbose(env, "old state:");
+                               print_verifier_state(env, sl->state.frame[cur->curframe], true);
                                return -EINVAL;
                        }
                        /* if the verifier is processing a loop, avoid adding new state