]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
bpf: Allow verifier to fixup kernel module kfuncs
authorAmery Hung <ameryhung@gmail.com>
Wed, 3 Dec 2025 23:37:43 +0000 (15:37 -0800)
committerAndrii Nakryiko <andrii@kernel.org>
Sat, 6 Dec 2025 00:17:57 +0000 (16:17 -0800)
Allow verifier to fixup kfuncs in kernel module to support kfuncs with
__prog arguments. Currently, special kfuncs and kfuncs with __prog
arguments are kernel kfuncs. Allowing kernel module kfuncs should not
affect existing kfunc fixup as kernel module kfuncs have BTF IDs greater
than kernel kfuncs' BTF IDs.

Signed-off-by: Amery Hung <ameryhung@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20251203233748.668365-2-ameryhung@gmail.com
kernel/bpf/verifier.c

index f0ca69f888fac2f1e6c03fd9dfae075ceb08a935..bb7eca1025c35ab5da5768b279918ee2395aa0de 100644 (file)
@@ -22493,8 +22493,7 @@ static int fixup_kfunc_call(struct bpf_verifier_env *env, struct bpf_insn *insn,
 
        if (!bpf_jit_supports_far_kfunc_call())
                insn->imm = BPF_CALL_IMM(desc->addr);
-       if (insn->off)
-               return 0;
+
        if (desc->func_id == special_kfunc_list[KF_bpf_obj_new_impl] ||
            desc->func_id == special_kfunc_list[KF_bpf_percpu_obj_new_impl]) {
                struct btf_struct_meta *kptr_struct_meta = env->insn_aux_data[insn_idx].kptr_struct_meta;