bpf: abort verification if env->cur_state->loop_entry != NULL

In addition to warning abort verification with -EFAULT.
If env->cur_state->loop_entry != NULL something is irrecoverably
buggy.

Fixes: bbbc02b744 ("bpf: copy_verifier_state() should copy 'loop_entry' field")
Suggested-by: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/r/20250225003838.135319-1-eddyz87@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
Eduard Zingerman 2025-02-24 16:38:38 -08:00 committed by Alexei Starovoitov
parent 1ffe30efd2
commit f3c2d243a3

View File

@ -19340,8 +19340,10 @@ static int do_check(struct bpf_verifier_env *env)
return err;
break;
} else {
if (WARN_ON_ONCE(env->cur_state->loop_entry))
env->cur_state->loop_entry = NULL;
if (WARN_ON_ONCE(env->cur_state->loop_entry)) {
verbose(env, "verifier bug: env->cur_state->loop_entry != NULL\n");
return -EFAULT;
}
do_print_state = true;
continue;
}