From: Eduard Zingerman Date: Tue, 25 Feb 2025 00:38:38 +0000 (-0800) Subject: bpf: abort verification if env->cur_state->loop_entry != NULL X-Git-Tag: v6.15-rc1~98^2~50 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f3c2d243a36ef23be07bc2bce7c6a5cb6e07d9e3;p=thirdparty%2Fkernel%2Flinux.git 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: bbbc02b7445e ("bpf: copy_verifier_state() should copy 'loop_entry' field") Suggested-by: Andrii Nakryiko Signed-off-by: Eduard Zingerman Acked-by: Andrii Nakryiko Link: https://lore.kernel.org/r/20250225003838.135319-1-eddyz87@gmail.com Signed-off-by: Alexei Starovoitov --- diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 5c9b7464ec2c9..942c0d2df258a 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -19340,8 +19340,10 @@ process_bpf_exit: 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; }