diff options
author | Kumar Kartikeya Dwivedi <memxor@gmail.com> | 2022-04-24 23:48:54 +0200 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2022-04-26 05:26:44 +0200 |
commit | 5ce937d613a423ca3102f53d9f3daf4210c1b6e2 (patch) | |
tree | 29ba398c7c3c275a1185a5466bf989c3a8914e98 /kernel/bpf/arraymap.c | |
parent | bpf: Adapt copy_map_value for multiple offset case (diff) | |
download | linux-5ce937d613a423ca3102f53d9f3daf4210c1b6e2.tar.xz linux-5ce937d613a423ca3102f53d9f3daf4210c1b6e2.zip |
bpf: Populate pairs of btf_id and destructor kfunc in btf
To support storing referenced PTR_TO_BTF_ID in maps, we require
associating a specific BTF ID with a 'destructor' kfunc. This is because
we need to release a live referenced pointer at a certain offset in map
value from the map destruction path, otherwise we end up leaking
resources.
Hence, introduce support for passing an array of btf_id, kfunc_btf_id
pairs that denote a BTF ID and its associated release function. Then,
add an accessor 'btf_find_dtor_kfunc' which can be used to look up the
destructor kfunc of a certain BTF ID. If found, we can use it to free
the object from the map free path.
The registration of these pairs also serve as a whitelist of structures
which are allowed as referenced PTR_TO_BTF_ID in a BPF map, because
without finding the destructor kfunc, we will bail and return an error.
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20220424214901.2743946-7-memxor@gmail.com
Diffstat (limited to 'kernel/bpf/arraymap.c')
0 files changed, 0 insertions, 0 deletions