mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-16 17:57:38 -04:00
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: 2f69c56854 ("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>
This commit is contained in:
committed by
Alexei Starovoitov
parent
a7e213a66a
commit
26490a375c
@@ -20006,13 +20006,13 @@ int bpf_check(struct bpf_prog **prog, union bpf_attr *attr, bpfptr_t uattr,
|
||||
if (!is_priv)
|
||||
mutex_unlock(&bpf_verifier_lock);
|
||||
bpf_clear_insn_aux_data(env, 0, env->prog->len);
|
||||
vfree(env->insn_aux_data);
|
||||
err_free_env:
|
||||
bpf_stack_liveness_free(env);
|
||||
kvfree(env->cfg.insn_postorder);
|
||||
kvfree(env->scc_info);
|
||||
kvfree(env->succ);
|
||||
kvfree(env->gotox_tmp_buf);
|
||||
vfree(env->insn_aux_data);
|
||||
kvfree(env);
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user