Re: [PATCH bpf v2 1/2] bpf: Skip detached progs in trampoline images that are still in use
From: Florent Revest
Date: Tue Sep 15 2026 - 14:41:05 EST
On Sat Sep 12, 2026 at 4:42 PM UTC, Alexei Starovoitov wrote:
> On Sat Sep 12, 2026 at 2:59 AM PDT, Florent Revest (Anthropic) wrote:
> > +struct bpf_tramp_skip {
> > + struct bpf_prog *prog;
>
> prog pointer shouldn't be necessary.
[...]
> > + void *nop;
> > + void *target;
> > +};
> > +
> > struct bpf_tramp_image {
> > void *image;
> > int size;
> > @@ -1374,8 +1389,27 @@ struct bpf_tramp_image {
> > struct rcu_head rcu;
> > struct work_struct work;
> > };
> > + /* entry in tr->images, the image holds a reference on tr */
> > + struct bpf_trampoline *tr;
> > + struct list_head list;
> > + struct bpf_tramp_skip *skips;
> > + int nr_skips;
>
> I don't follow why you need link list and 'tr' pointer here.
> Also why keep ip_after_call ?
>
> Replace ip_after_call with array of bpf_tramp_skip { void *nop, *target; }
> and then in bpf_tramp_image_put() instead of ip_after_call do:
> for (i = 0; i < im->nr_skips; i++) {
> struct bpf_tramp_skip *skip = &im->skips[i];
>
> err = bpf_arch_text_poke(skip->nop, BPF_MOD_NOP, BPF_MOD_JUMP,
> NULL, skip->target);
> }
>
> what am I missing?
Ah yeah, I tried to address that in the cover letter. Basically, if we patch
all the nops, tasks running in the old image could skip some progs that are
still attached. For fexit, that's already what happens with ip_after_call but
for fmod_ret it would be new and this would cause for example an LSM prog's
verdict to get skipped when another prog gets attached to the same hook. That's
why I thought that patching only the detached prog's nop would be better and
needed these extra pointers. But it's a bit of an edge case and I don't have a
strong opinion on it.
If you'd prefer the simpler version, I can do what you suggested here in v3. If
you'd rather only skip the detached progs, then yeah, I think ip_after_call
wasn't needed anymore and I should have dropped it too.