]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
bpf: Handle allocation failure in acquire_lock_state
authorKumar Kartikeya Dwivedi <memxor@gmail.com>
Thu, 6 Feb 2025 10:54:31 +0000 (02:54 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Sat, 8 Feb 2025 02:17:07 +0000 (18:17 -0800)
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@gmail.com>
Link: https://lore.kernel.org/r/20250206105435.2159977-24-memxor@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/verifier.c

index 98354d7816789b725caa4032f65d1cda045fd14a..60611df77957a5eb807eebd86bab8efe2943d2c7 100644 (file)
@@ -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;
        s->type = type;
        s->id = id;
        s->ptr = ptr;