summaryrefslogtreecommitdiffstats
path: root/kernel/bpf/map_iter.c
diff options
context:
space:
mode:
authorAnton Protopopov <aspsk@isovalent.com>2023-07-19 09:29:50 +0000
committerAlexei Starovoitov <ast@kernel.org>2023-07-19 09:48:52 -0700
commit5ba190c29cf92f157bd63c9909c7050d6dc43df7 (patch)
tree486ef54af06582d7b78ab480a9ca0f7826915f32 /kernel/bpf/map_iter.c
parent831deb2976de4458adae4daee56aa6f740ed4acc (diff)
downloadlinux-5ba190c29cf92f157bd63c9909c7050d6dc43df7.tar.gz
linux-5ba190c29cf92f157bd63c9909c7050d6dc43df7.tar.bz2
linux-5ba190c29cf92f157bd63c9909c7050d6dc43df7.zip
bpf: consider CONST_PTR_TO_MAP as trusted pointer to struct bpf_map
Add the BTF id of struct bpf_map to the reg2btf_ids array. This makes the values of the CONST_PTR_TO_MAP type to be considered as trusted by kfuncs. This, in turn, allows users to execute trusted kfuncs which accept `struct bpf_map *` arguments from non-tracing programs. While exporting the btf_bpf_map_id variable, save some bytes by defining it as BTF_ID_LIST_GLOBAL_SINGLE (which is u32[1]) and not as BTF_ID_LIST (which is u32[64]). Signed-off-by: Anton Protopopov <aspsk@isovalent.com> Link: https://lore.kernel.org/r/20230719092952.41202-3-aspsk@isovalent.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'kernel/bpf/map_iter.c')
-rw-r--r--kernel/bpf/map_iter.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/kernel/bpf/map_iter.c b/kernel/bpf/map_iter.c
index d06d3b7150e5..b67996147895 100644
--- a/kernel/bpf/map_iter.c
+++ b/kernel/bpf/map_iter.c
@@ -78,8 +78,7 @@ static const struct seq_operations bpf_map_seq_ops = {
.show = bpf_map_seq_show,
};
-BTF_ID_LIST(btf_bpf_map_id)
-BTF_ID(struct, bpf_map)
+BTF_ID_LIST_GLOBAL_SINGLE(btf_bpf_map_id, struct, bpf_map)
static const struct bpf_iter_seq_info bpf_map_seq_info = {
.seq_ops = &bpf_map_seq_ops,