Re: [RFC PATCH bpf-next 01/17] bpf: Link shimlink directly in trampoline

Jiri Olsa
2022-08-09T15:37:43Z

On Mon, Aug 08, 2022 at 10:58:36AM -0700, Stanislav Fomichev wrote:
> On Mon, Aug 8, 2022 at 10:40 AM Song Liu <song@kernel.org> wrote:
> >
> > On Mon, Aug 8, 2022 at 7:06 AM Jiri Olsa <jolsa@kernel.org> wrote:
> > >
> > > We are going to get rid of struct bpf_tramp_link in following
> > > changes and cgroup_shim_find logic does not fit to that.
> > >
> > > We can store the link directly in the trampoline and omit the
> > > cgroup_shim_find searching logic.
> > >
> > > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> > > ---
> > > include/linux/bpf.h | 3 +++
> > > kernel/bpf/trampoline.c | 23 +++--------------------
> > > 2 files changed, 6 insertions(+), 20 deletions(-)
> > >
> > > diff --git a/include/linux/bpf.h b/include/linux/bpf.h
> > > index 20c26aed7896..ed2a921094bc 100644
> > > --- a/include/linux/bpf.h
> > > +++ b/include/linux/bpf.h
> > > @@ -841,6 +841,8 @@ struct bpf_tramp_image {
> > > };
> > > };
> > >
> > > +struct bpf_shim_tramp_link;
> > > +
> > > struct bpf_trampoline {
> > > /* hlist for trampoline_table */
> > > struct hlist_node hlist;
> > > @@ -868,6 +870,7 @@ struct bpf_trampoline {
> > > struct bpf_tramp_image *cur_image;
> > > u64 selector;
> > > struct module *mod;
> > > + struct bpf_shim_tramp_link *shim_link;
> > > };
> >
> > Hi Stanislav,
> >
> > Is it possible to have multiple shim_link per bpf_trampoline? If so, I guess
> > this won't work.
>
> There is only one shim_link per bpf_trampoline. But I'm not sure
> storing the pointer is enough. We have to do 'shim_link=NULL' when the
> (final) shim is removed. (multiple lsm_cgroup progs can share the same
> shim)

ok, will check on that

thanks,
jirka