On Sat, Dec 18, 2021 at 8:38 PM Kumar Kartikeya Dwivedi <memxor@xxxxxxxxx> wrote: > > On Sun, Dec 19, 2021 at 09:24:37AM IST, Alexei Starovoitov wrote: > > On Sat, Dec 18, 2021 at 7:01 PM Kumar Kartikeya Dwivedi > > <memxor@xxxxxxxxx> wrote: > > > > > > On Sun, Dec 19, 2021 at 07:52:48AM IST, Alexei Starovoitov wrote: > > > > On Fri, Dec 17, 2021 at 07:20:26AM +0530, Kumar Kartikeya Dwivedi wrote: > > > > > > > > > > diff --git a/include/linux/bpf.h b/include/linux/bpf.h > > > > > index 965fffaf0308..015cb633838b 100644 > > > > > --- a/include/linux/bpf.h > > > > > +++ b/include/linux/bpf.h > > > > > @@ -521,6 +521,9 @@ struct bpf_verifier_ops { > > > > > enum bpf_access_type atype, > > > > > u32 *next_btf_id); > > > > > bool (*check_kfunc_call)(u32 kfunc_btf_id, struct module *owner); > > > > > + bool (*is_acquire_kfunc)(u32 kfunc_btf_id, struct module *owner); > > > > > + bool (*is_release_kfunc)(u32 kfunc_btf_id, struct module *owner); > > > > > + bool (*is_kfunc_ret_type_null)(u32 kfunc_btf_id, struct module *owner); > > > > > > > > Same feedback as before... > > > > > > > > Those callbacks are not necessary. > > > > The existing check_kfunc_call() is just as inconvenient. > > > > When module's BTF comes in could you add it to mod's info instead of > > > > introducing callbacks for every kind of data the module has. > > > > Those callbacks don't server any purpose other than passing the particular > > > > data set back. The verifier side should access those data sets directly. > > > > > > Ok, interesting idea. So these then go into the ".modinfo" section? > > > > It doesn't need to be a special section. > > The btf_module_notify() parses BTF. > > At the same time it can add a kfunc whitelist to "struct module". > > The btf_ids[ACQUIRE/RELEASE][] arrays will be a part of > > the "struct module" too. > > If we can do a btf name convention then this job can be > > performed generically by btf_module_notify(). > > Otherwise __init of the module can populate arrays in "struct module". > > > > Nice idea, I think this is better than what I am doing (it also prevents > constant researching into the list). > > But IIUC I think this btf_ids array needs to go into struct btf instead, > since if module is compiled as built-in, we will not have any struct module for > it. > > Then we can concatenate all sets of same type (check/acquire/release etc.) and > sort them to directly search using a single btf_id_set_contains call, the code > becomes same for btf_vmlinux or module btf. struct module is not needed anymore. > > WDYT? You mean that btf_parse_module() will do this? That would work for vmlinux's BTF too then? Makes sense to me!