diff options
author | Kui-Feng Lee <thinker.li@gmail.com> | 2024-01-19 14:50:01 -0800 |
---|---|---|
committer | Martin KaFai Lau <martin.lau@kernel.org> | 2024-01-23 16:37:45 -0800 |
commit | 612d087d4ba54cef47946e22e5dabad762dd7ed5 (patch) | |
tree | 7044e668fc1d4277daac80e05425caf566aedc02 /include/linux/bpf.h | |
parent | bpf: hold module refcnt in bpf_struct_ops map creation and prog verification. (diff) | |
download | linux-612d087d4ba54cef47946e22e5dabad762dd7ed5.tar.xz linux-612d087d4ba54cef47946e22e5dabad762dd7ed5.zip |
bpf: validate value_type
A value_type should consist of three components: refcnt, state, and data.
refcnt and state has been move to struct bpf_struct_ops_common_value to
make it easier to check the value type.
Signed-off-by: Kui-Feng Lee <thinker.li@gmail.com>
Link: https://lore.kernel.org/r/20240119225005.668602-11-thinker.li@gmail.com
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Diffstat (limited to 'include/linux/bpf.h')
-rw-r--r-- | include/linux/bpf.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/include/linux/bpf.h b/include/linux/bpf.h index a5b425893d38..7c178170f93f 100644 --- a/include/linux/bpf.h +++ b/include/linux/bpf.h @@ -1688,6 +1688,18 @@ struct bpf_struct_ops_desc { u32 value_id; }; +enum bpf_struct_ops_state { + BPF_STRUCT_OPS_STATE_INIT, + BPF_STRUCT_OPS_STATE_INUSE, + BPF_STRUCT_OPS_STATE_TOBEFREE, + BPF_STRUCT_OPS_STATE_READY, +}; + +struct bpf_struct_ops_common_value { + refcount_t refcnt; + enum bpf_struct_ops_state state; +}; + #if defined(CONFIG_BPF_JIT) && defined(CONFIG_BPF_SYSCALL) #define BPF_MODULE_OWNER ((void *)((0xeB9FUL << 2) + POISON_POINTER_DELTA)) const struct bpf_struct_ops_desc *bpf_struct_ops_find(struct btf *btf, u32 type_id); |