Skip to content

Commit 9ee9822

Browse files
anakryikoAlexei Starovoitov
authored andcommitted
bpf: save extended inner map info for percpu array maps as well
ARRAY_OF_MAPS and HASH_OF_MAPS map types have special logic to save a few extra fields required for correct operations of ARRAY maps, when they are used as inner maps. PERCPU_ARRAY maps have similar requirements as they now support generating inline element lookup logic. So make sure that both classes of maps are handled correctly. Reported-by: Jakub Kicinski <kuba@kernel.org> Fixes: db69718 ("bpf: inline bpf_map_lookup_elem() for PERCPU_ARRAY maps") Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Acked-by: Kumar Kartikeya Dwivedi <memxor@gmail.com> Link: https://lore.kernel.org/r/20240515062440.846086-1-andrii@kernel.org Signed-off-by: Alexei Starovoitov <ast@kernel.org>
1 parent 325423c commit 9ee9822

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

kernel/bpf/map_in_map.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ struct bpf_map *bpf_map_meta_alloc(int inner_map_ufd)
3232

3333
inner_map_meta_size = sizeof(*inner_map_meta);
3434
/* In some cases verifier needs to access beyond just base map. */
35-
if (inner_map->ops == &array_map_ops)
35+
if (inner_map->ops == &array_map_ops || inner_map->ops == &percpu_array_map_ops)
3636
inner_map_meta_size = sizeof(struct bpf_array);
3737

3838
inner_map_meta = kzalloc(inner_map_meta_size, GFP_USER);
@@ -68,7 +68,7 @@ struct bpf_map *bpf_map_meta_alloc(int inner_map_ufd)
6868

6969
/* Misc members not needed in bpf_map_meta_equal() check. */
7070
inner_map_meta->ops = inner_map->ops;
71-
if (inner_map->ops == &array_map_ops) {
71+
if (inner_map->ops == &array_map_ops || inner_map->ops == &percpu_array_map_ops) {
7272
struct bpf_array *inner_array_meta =
7373
container_of(inner_map_meta, struct bpf_array, map);
7474
struct bpf_array *inner_array = container_of(inner_map, struct bpf_array, map);

0 commit comments

Comments
 (0)