[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMB2axOQqgpiUTb-33uOgYar48PM=DTeOFAZY3P3FYk16Dy33Q@mail.gmail.com>
Date: Thu, 16 Oct 2025 11:29:57 -0700
From: Amery Hung <ameryhung@...il.com>
To: Andrii Nakryiko <andrii.nakryiko@...il.com>
Cc: bpf@...r.kernel.org, netdev@...r.kernel.org, alexei.starovoitov@...il.com,
andrii@...nel.org, daniel@...earbox.net, tj@...nel.org, martin.lau@...nel.org,
kernel-team@...a.com
Subject: Re: [RFC PATCH v1 bpf-next 1/4] bpf: Allow verifier to fixup kernel
module kfuncs
On Mon, Oct 13, 2025 at 5:11 PM Andrii Nakryiko
<andrii.nakryiko@...il.com> wrote:
>
> On Fri, Oct 10, 2025 at 10:49 AM Amery Hung <ameryhung@...il.com> wrote:
> >
> > 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. As there is no safety reason that prevents
> > a kernel module kfunc from accessing prog->aux, allow it by removing the
> > kernel BTF check.
>
> I'd just clarify that this should be fine and shouldn't confuse all
> those desc->func_id comparisons because BTF IDs in module BTF are
> always greater than any of vmlinux BTF ID due to split BTF setup.
Got it. I will make the commit message less confusing.
>
>
> >
> > Signed-off-by: Amery Hung <ameryhung@...il.com>
> > ---
> > kernel/bpf/verifier.c | 3 +--
> > 1 file changed, 1 insertion(+), 2 deletions(-)
> >
> > diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> > index e892df386eed..d5f1046d08b7 100644
> > --- a/kernel/bpf/verifier.c
> > +++ b/kernel/bpf/verifier.c
> > @@ -21889,8 +21889,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;
> > --
> > 2.47.3
> >
Powered by blists - more mailing lists