summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAmery Hung <ameryhung@gmail.com>2026-05-28 18:49:25 -0700
committerAlexei Starovoitov <ast@kernel.org>2026-06-01 18:31:40 -0700
commitb5c0a07eb2c23bfd0c42ad6b461e6881b4b0995b (patch)
tree1eb9b84f144e4fdb3975f4e0986e5688cc7661b5 /include
parentbab08d1f70438cf06de9ab438313b7ef3099514c (diff)
downloadlinux-next-b5c0a07eb2c23bfd0c42ad6b461e6881b4b0995b.tar.gz
linux-next-b5c0a07eb2c23bfd0c42ad6b461e6881b4b0995b.zip
bpf: Unify dynptr handling in the verifier
Simplify dynptr checking for helper and kfunc by unifying it. Remember the initialized dynptr (i.e.,g !(arg_type |= MEM_UNINIT)) pass to a dynptr kfunc during process_dynptr_func() so that we can easily retrieve the information for verification later. By saving it in meta->dynptr, there is no need to call dynptr helpers such as dynptr_id(), dynptr_ref_obj_id() and dynptr_type() in check_func_arg(). Remove and open code the helpers in process_dynptr_func() when saving id, ref_obj_id, and type. Besides, since dynptr ref_obj_id information is now pass around in meta->bpf_dynptr_desc, drop the check in helper_multiple_ref_obj_use. Acked-by: Eduard Zingerman <eddyz87@gmail.com> Acked-by: Mykyta Yatsenko <yatsenko@meta.com> Signed-off-by: Amery Hung <ameryhung@gmail.com> Link: https://lore.kernel.org/r/20260529014936.2811085-3-ameryhung@gmail.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/bpf_verifier.h13
1 files changed, 8 insertions, 5 deletions
diff --git a/include/linux/bpf_verifier.h b/include/linux/bpf_verifier.h
index 5cbad3b64130..3a5c226bf1c3 100644
--- a/include/linux/bpf_verifier.h
+++ b/include/linux/bpf_verifier.h
@@ -1438,6 +1438,13 @@ struct bpf_map_desc {
int uid;
};
+/* The last initialized dynptr; Populated by process_dynptr_func() */
+struct bpf_dynptr_desc {
+ enum bpf_dynptr_type type;
+ u32 id;
+ u32 ref_obj_id;
+};
+
struct bpf_kfunc_call_arg_meta {
/* In parameters */
struct btf *btf;
@@ -1479,15 +1486,11 @@ struct bpf_kfunc_call_arg_meta {
struct btf_field *field;
} arg_rbtree_root;
struct {
- enum bpf_dynptr_type type;
- u32 id;
- u32 ref_obj_id;
- } initialized_dynptr;
- struct {
u8 spi;
u8 frameno;
} iter;
struct bpf_map_desc map;
+ struct bpf_dynptr_desc dynptr;
u64 mem_size;
};