]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
bpf: Fix dead error check on acquire_reference() in check_kfunc_call
authorAmery Hung <ameryhung@gmail.com>
Fri, 5 Jun 2026 20:20:52 +0000 (13:20 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 5 Jun 2026 21:18:19 +0000 (14:18 -0700)
acquire_reference() returns a signed int that may be a negative errno
but was converted to unsigned, which makes the subsequent error check
deadcode. Fix it by declaring 'id' as int so the error path is taken
correctly.

Fixes: 308c7a0ae885 ("bpf: Refactor object relationship tracking and fix dynptr UAF bug")
Acked-by: Eduard Zingerman <eddyz87@gmail.com>
Signed-off-by: Amery Hung <ameryhung@gmail.com>
Link: https://lore.kernel.org/r/20260605202056.1780352-2-ameryhung@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/verifier.c

index 7d27ba396d3265264adbe69cd9cc7a06bb8d8668..a741bf4479318154590df9123edda4cfddb5e561 100644 (file)
@@ -12817,9 +12817,10 @@ static int check_kfunc_call(struct bpf_verifier_env *env, struct bpf_insn *insn,
        struct bpf_kfunc_call_arg_meta meta;
        struct bpf_insn_aux_data *insn_aux;
        int err, insn_idx = *insn_idx_p;
-       u32 i, nargs, ptr_type_id, id;
        const struct btf_param *args;
+       u32 i, nargs, ptr_type_id;
        struct btf *desc_btf;
+       int id;
 
        /* skip for now, but return error when we find this in fixup_kfunc_call */
        if (!insn->imm)