]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
bpf: Fix insn_aux_data leak on verifier err_free_env path
authorKaFai Wan <kafai.wan@linux.dev>
Wed, 24 Jun 2026 12:35:35 +0000 (20:35 +0800)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 26 Jun 2026 01:23:56 +0000 (18:23 -0700)
commit26490a375cb9be9bac96b5171610fd85ca6c2305
tree3e93c25f83494f0b9313ceb38dd870bef979b492
parenta7e213a66adda0c13936ad920c5501acc54c1c25
bpf: Fix insn_aux_data leak on verifier err_free_env path

When bpf_check() allocates env->insn_aux_data successfully but later
fails to allocate env->succ, it jumps directly to err_free_env.

The existing vfree(env->insn_aux_data) sits before the err_free_env
label, so that direct jump bypasses it and leaks insn_aux_data.

Move vfree(env->insn_aux_data) into err_free_env so all early and late
exit paths release it consistently.

Fixes: 2f69c5685427 ("bpf: make bpf_insn_successors to return a pointer")
Signed-off-by: KaFai Wan <kafai.wan@linux.dev>
Reviewed-by: Anton Protopopov <a.s.protopopov@gmail.com>
Link: https://lore.kernel.org/r/20260624123536.114757-1-kafai.wan@linux.dev
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/verifier.c