mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-24 05:01:03 +02:00
bpf: Add kfunc filter function to 'struct btf_kfunc_id_set'
This commit adds the ability to filter kfuncs to certain BPF program types. This is required to limit bpf_sock_destroy kfunc implemented in follow-up commits to programs with attach type 'BPF_TRACE_ITER'. The commit adds a callback filter to 'struct btf_kfunc_id_set'. The filter has access to the `bpf_prog` construct including its properties such as `expected_attached_type`. Signed-off-by: Aditi Ghag <aditi.ghag@isovalent.com> Link: https://lore.kernel.org/r/20230519225157.760788-7-aditi.ghag@isovalent.com Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
This commit is contained in:
committed by
Martin KaFai Lau
parent
c96dac8d36
commit
e924e80ee6
@@ -98,10 +98,14 @@ struct btf_type;
|
||||
union bpf_attr;
|
||||
struct btf_show;
|
||||
struct btf_id_set;
|
||||
struct bpf_prog;
|
||||
|
||||
typedef int (*btf_kfunc_filter_t)(const struct bpf_prog *prog, u32 kfunc_id);
|
||||
|
||||
struct btf_kfunc_id_set {
|
||||
struct module *owner;
|
||||
struct btf_id_set8 *set;
|
||||
btf_kfunc_filter_t filter;
|
||||
};
|
||||
|
||||
struct btf_id_dtor_kfunc {
|
||||
@@ -479,7 +483,6 @@ static inline void *btf_id_set8_contains(const struct btf_id_set8 *set, u32 id)
|
||||
return bsearch(&id, set->pairs, set->cnt, sizeof(set->pairs[0]), btf_id_cmp_func);
|
||||
}
|
||||
|
||||
struct bpf_prog;
|
||||
struct bpf_verifier_log;
|
||||
|
||||
#ifdef CONFIG_BPF_SYSCALL
|
||||
@@ -487,10 +490,10 @@ const struct btf_type *btf_type_by_id(const struct btf *btf, u32 type_id);
|
||||
const char *btf_name_by_offset(const struct btf *btf, u32 offset);
|
||||
struct btf *btf_parse_vmlinux(void);
|
||||
struct btf *bpf_prog_get_target_btf(const struct bpf_prog *prog);
|
||||
u32 *btf_kfunc_id_set_contains(const struct btf *btf,
|
||||
enum bpf_prog_type prog_type,
|
||||
u32 kfunc_btf_id);
|
||||
u32 *btf_kfunc_is_modify_return(const struct btf *btf, u32 kfunc_btf_id);
|
||||
u32 *btf_kfunc_id_set_contains(const struct btf *btf, u32 kfunc_btf_id,
|
||||
const struct bpf_prog *prog);
|
||||
u32 *btf_kfunc_is_modify_return(const struct btf *btf, u32 kfunc_btf_id,
|
||||
const struct bpf_prog *prog);
|
||||
int register_btf_kfunc_id_set(enum bpf_prog_type prog_type,
|
||||
const struct btf_kfunc_id_set *s);
|
||||
int register_btf_fmodret_id_set(const struct btf_kfunc_id_set *kset);
|
||||
@@ -517,8 +520,9 @@ static inline const char *btf_name_by_offset(const struct btf *btf,
|
||||
return NULL;
|
||||
}
|
||||
static inline u32 *btf_kfunc_id_set_contains(const struct btf *btf,
|
||||
enum bpf_prog_type prog_type,
|
||||
u32 kfunc_btf_id)
|
||||
u32 kfunc_btf_id,
|
||||
struct bpf_prog *prog)
|
||||
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
Reference in New Issue
Block a user