> On Thu, Nov 23, 2023 at 03:25:33PM +0100, Jiri Olsa wrote: > > + link->prog->aux->attach_depth--; > > should we just set it to 0 ? the number is assigned from tgt_prog, so I think we'll > endup with wrong up number here after detach (for both tgt_prog or kernel function) > > + 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; > > + } > > missing cleanup/dec if the next bpf_trampoline_link_prog call fails? > probably better move that accounting after that call > > + printf(" attach depth %d", info->attach_depth); > > + > > I think we should print only if the value != 0 like we do for other fields > > + if (tgt_prog->type == prog->type && > > + (prog_extension || prog->aux->follower_cnt > 0)) { > > + /* > > + * To avoid potential call chain cycles, prevent attaching programs > > + * of the same type. The only exception is standalone fentry/fexit > > + * programs that themselves are not attachment targets. > > + * That means: > > + * - Cannot attach followed fentry/fexit to another > > + * fentry/fexit program. > > + * - Cannot attach program extension to another extension. > > would be great to have tests for this Agree on all points, thanks. Will post the updated version soon.