On Tue, Feb 03, 2026 at 10:14:02AM +0000, [email protected] wrote:
> > diff --git a/kernel/bpf/trampoline.c b/kernel/bpf/trampoline.c
> > index 2be2f1d0b..b76bb5450 100644
> > --- a/kernel/bpf/trampoline.c
> > +++ b/kernel/bpf/trampoline.c
> 
> [ ... ]
> 
> > +int bpf_trampoline_multi_attach(struct bpf_prog *prog, u32 *ids,
> > +                           struct bpf_tracing_multi_link *link)
> > +{
> > +   struct bpf_attach_target_info tgt_info = {};
> > +   struct bpf_tracing_multi_node *mnode;
> > +   int j, i, err, cnt = link->nodes_cnt;
> > +   struct fentry_multi_data data = {};
> > +   struct bpf_trampoline *tr;
> > +   u64 key;
> > +
> > +   data.reg = alloc_ftrace_hash(FTRACE_HASH_DEFAULT_BITS);
> > +   if (!data.reg)
> > +           return -ENOMEM;
> > +
> > +   data.modify = alloc_ftrace_hash(FTRACE_HASH_DEFAULT_BITS);
> > +   if (!data.modify) {
> > +           free_ftrace_hash(data.reg);
> > +           return -ENOMEM;
> > +   }
> > +
> > +   for (i = 0; i < cnt; i++) {
> > +           mnode = &link->nodes[i];
> > +           err = bpf_check_attach_target(NULL, prog, NULL, ids[i], 
> > &tgt_info);
> > +           if (err)
> > +                   goto rollback_put;
> > +
> > +           key = bpf_trampoline_compute_key(NULL, prog->aux->attach_btf, 
> > ids[i]);
> > +
> > +           tr = bpf_trampoline_get(key, &tgt_info);
> > +           if (!tr)
> > +                   goto rollback_put;
> 
> When bpf_trampoline_get() returns NULL here, the code jumps to
> rollback_put without setting err. If bpf_check_attach_target() succeeded
> on this iteration (setting err to 0), the function will return 0 instead
> of an error code.
> 
> Should this be something like:
> 
>     tr = bpf_trampoline_get(key, &tgt_info);
>     if (!tr) {
>         err = -ENOMEM;
>         goto rollback_put;
>     }
> 

yep, we should, will add, thnx

jirka

> > +
> > +           mnode->trampoline = tr;
> > +           mnode->node.prog = prog;
> > +   }
> 
> [ ... ]
> 
> > +rollback_put:
> > +   for (j = 0; j < i; j++) {
> > +           mnode = &link->nodes[j];
> > +           bpf_trampoline_put(mnode->trampoline);
> > +   }
> > +
> > +   free_fentry_multi_data(&data);
> > +   return err;
> > +}
> 
> 
> ---
> AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
> See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
> 
> CI run summary: https://github.com/kernel-patches/bpf/actions/runs/21625440628
> 
> AI-authorship-score: low
> AI-authorship-explanation: The code follows established kernel patterns and 
> contains a human-typical oversight error (missing error assignment); the 
> commit message has a minor copy-paste error typical of human editing.
> issues-found: 1
> issue-severity-score: low
> issue-severity-explanation: Missing error code when bpf_trampoline_get fails 
> causes silent failure under memory pressure, but does not cause crashes or 
> data corruption.


Reply via email to