On Fri, Jul 26, 2024 at 01:43:45PM -0700, Alexei Starovoitov wrote: > On Fri, Jul 26, 2024 at 1:56 AM Matt Bobrowski <mattbobrowski@xxxxxxxxxx> wrote: > > + > > +static int bpf_fs_kfuncs_filter(const struct bpf_prog *prog, u32 kfunc_id) > > +{ > > + if (!btf_id_set8_contains(&bpf_fs_kfunc_set_ids, kfunc_id) || > > + prog->type == BPF_PROG_TYPE_LSM) > > + return 0; > > + return -EACCES; > > +} > > + > > +static const struct btf_kfunc_id_set bpf_fs_kfunc_set = { > > + .owner = THIS_MODULE, > > + .set = &bpf_fs_kfunc_set_ids, > > + .filter = bpf_fs_kfuncs_filter, > > +}; > > + > > +static int __init bpf_fs_kfuncs_init(void) > > +{ > > + return register_btf_kfunc_id_set(BPF_PROG_TYPE_LSM, &bpf_fs_kfunc_set); > > +} > > Aside from buf__sz <= 0 that Christian spotted I'm going to fix this up in v2 of this patch, so don't worry about it. > the bpf_fs_kfuncs_filter() is a watery water. > It's doing a redundant check that is already covered by > > register_btf_kfunc_id_set(BPF_PROG_TYPE_LSM,... > > I'll remove it while applying. As discussed, this filter is currently required as without it we inadvertently allow tracing BPF programs to also use these BPF kfuncs. /M