On Fri, Apr 29, 2022 at 2:15 PM Stanislav Fomichev <sdf@xxxxxxxxxx> wrote: > > We have two options: > 1. Treat all BPF_LSM_CGROUP as the same, regardless of attach_btf_id > 2. Treat BPF_LSM_CGROUP+attach_btf_id as a separate hook point > > I'm doing (2) here and adding attach_btf_id as a new BPF_PROG_QUERY > argument. The downside is that it requires iterating over all possible > bpf_lsm_ hook points in the userspace which might take some time. > > Signed-off-by: Stanislav Fomichev <sdf@xxxxxxxxxx> > --- > include/uapi/linux/bpf.h | 1 + > kernel/bpf/cgroup.c | 43 ++++++++++++++++++++++++---------- > kernel/bpf/syscall.c | 3 ++- > tools/include/uapi/linux/bpf.h | 1 + > tools/lib/bpf/bpf.c | 42 ++++++++++++++++++++++++++------- > tools/lib/bpf/bpf.h | 15 ++++++++++++ > tools/lib/bpf/libbpf.map | 1 + please split kernel and libbpf changes into separate patches and mark libbpf's with "libbpf: " prefix > 7 files changed, 85 insertions(+), 21 deletions(-) > [...] > diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c > index a9d292c106c2..f62823451b99 100644 > --- a/tools/lib/bpf/bpf.c > +++ b/tools/lib/bpf/bpf.c > @@ -946,28 +946,54 @@ int bpf_iter_create(int link_fd) > return libbpf_err_errno(fd); > } > > -int bpf_prog_query(int target_fd, enum bpf_attach_type type, __u32 query_flags, > - __u32 *attach_flags, __u32 *prog_ids, __u32 *prog_cnt) > +int bpf_prog_query2(int target_fd, this would have to be named bpf_prog_query_opts() > + enum bpf_attach_type type, > + struct bpf_prog_query_opts *opts) > { > union bpf_attr attr; > int ret; > > memset(&attr, 0, sizeof(attr)); > + [...] > diff --git a/tools/lib/bpf/libbpf.map b/tools/lib/bpf/libbpf.map > index b5bc84039407..5e5bb3e437cc 100644 > --- a/tools/lib/bpf/libbpf.map > +++ b/tools/lib/bpf/libbpf.map > @@ -450,4 +450,5 @@ LIBBPF_0.8.0 { > bpf_program__attach_usdt; > libbpf_register_prog_handler; > libbpf_unregister_prog_handler; > + bpf_prog_query2; this list is alphabetically ordered > } LIBBPF_0.7.0; > -- > 2.36.0.464.gb9c8b46e94-goog >