Re: [RFC PATCH bpf-next v2] bpf: Relax tracing prog recursive attach rules

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> On Thu, Nov 23, 2023 at 11:24:34PM -0800, Song Liu wrote:
> > Following the corresponding discussion [1], the reason for that is to
> > avoid tracing progs call cycles without introducing more complex
> > solutions. Relax "no same type" requirement to "no progs that are
> > already an attach target themselves" for the tracing type. In this way
> > only a standalone tracing program (without any other progs attached to
> > it) could be attached to another one, and no cycle could be formed. To
>
> If prog B attached to prog A, and prog C attached to prog B, then we
> detach B. At this point, can we re-attach B to A?

Nope, with the proposed changes it still wouldn't be possible to
reattach B to A (if we're talking about tracing progs of course),
because this time B is an attachment target on its own.

> > +       if (tgt_prog) {
> > +               /* Bookkeeping for managing the prog attachment chain. */
> > +               tgt_prog->aux->follower_cnt++;
> > +               prog->aux->attach_depth = tgt_prog->aux->attach_depth + 1;
> > +       }
> > +
>
> attach_depth is calculated at attach time, so...
>
> >                 struct bpf_prog_aux *aux = tgt_prog->aux;
> >
> > +               if (aux->attach_depth >= 32) {
> > +                       bpf_log(log, "Target program attach depth is %d. Too large\n",
> > +                                       aux->attach_depth);
> > +                       return -EINVAL;
> > +               }
> > +
>
> (continue from above) attach_depth is always 0 at program load time, no?

Right, it's going to be always 0 for the just loaded program -- but here
in verifier we check attach_depth of the target program, which is
calculated at some point before. Or were you asking about something else?




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux