Re: [PATCH bpf-next v2 23/26] bpf: Handle allocation failure in acquire_lock_state

From: Alexei Starovoitov
Date: Fri Feb 07 2025 - 21:05:13 EST


On Thu, Feb 6, 2025 at 2:55 AM Kumar Kartikeya Dwivedi <memxor@xxxxxxxxx> wrote:
>
> The acquire_lock_state function needs to handle possible NULL values
> returned by acquire_reference_state, and return -ENOMEM.
>
> Fixes: 769b0f1c8214 ("bpf: Refactor {acquire,release}_reference_state")
> Signed-off-by: Kumar Kartikeya Dwivedi <memxor@xxxxxxxxx>
> ---
> kernel/bpf/verifier.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index 9971c03adfd5..d6999d085c7d 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
> @@ -1501,6 +1501,8 @@ static int acquire_lock_state(struct bpf_verifier_env *env, int insn_idx, enum r
> struct bpf_reference_state *s;
>
> s = acquire_reference_state(env, insn_idx);
> + if (!s)
> + return -ENOMEM;

I'll grab this fix into bpf tree.
Next time just send it separately, so the fix is not lost
in the patch bomb.