On Fri, Oct 24, 2025 at 5:11 PM Steven Rostedt <[email protected]> wrote:
>
> On Fri, 24 Oct 2025 11:29:00 -0700
> Song Liu <[email protected]> wrote:
>
> > --- a/kernel/bpf/trampoline.c
> > +++ b/kernel/bpf/trampoline.c
> > @@ -221,6 +221,13 @@ static int register_fentry(struct bpf_trampoline *tr, 
> > void *new_addr)
> >
> >       if (tr->func.ftrace_managed) {
> >               ftrace_set_filter_ip(tr->fops, (unsigned long)ip, 0, 1);
> > +             /*
> > +              * Clearing fops->trampoline and fops->NULL is
> > +              * needed by the "goto again" case in
> > +              * bpf_trampoline_update().
> > +              */
> > +             tr->fops->trampoline = 0;
> > +             tr->fops->func = NULL;
> >               ret = register_ftrace_direct(tr->fops, (long)new_addr);
> >       } else {
> >               ret = bpf_arch_text_poke(ip, BPF_MOD_CALL, NULL, new_addr);
>
> I ran these through my own tests and this failed to build:
>
> /work/build/trace/nobackup/linux-test.git/kernel/bpf/trampoline.c: In 
> function ‘register_fentry’:
> /work/build/trace/nobackup/linux-test.git/kernel/bpf/trampoline.c:229:25: 
> error: invalid use of undefined type ‘struct ftrace_ops’
>   229 |                 tr->fops->trampoline = 0;
>       |                         ^~
> /work/build/trace/nobackup/linux-test.git/kernel/bpf/trampoline.c:230:25: 
> error: invalid use of undefined type ‘struct ftrace_ops’
>   230 |                 tr->fops->func = NULL;
>       |                         ^~
>   CC      kernel/trace/rethook.o
> make[5]: *** 
> [/work/build/trace/nobackup/linux-test.git/scripts/Makefile.build:287: 
> kernel/bpf/trampoline.o] Error 1
> make[5]: *** Waiting for unfinished jobs....
>
> Config attched.

We need to guard this part with CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS.
The suggestion by AI should also fix this, and give cleaner code.

Thanks,
Song

Reply via email to