Skip to content

Commit 3bcd604

Browse files
author
Alexei Starovoitov
committed
Merge branch 'inner_map_spin_lock-fix'
Yonghong Song says: ==================== The inner_map_meta->spin_lock_off is not set correctly during map creation for BPF_MAP_TYPE_ARRAY_OF_MAPS and BPF_MAP_TYPE_HASH_OF_MAPS. This may lead verifier error due to misinformation. This patch set fixed the issue with Patch raspberrypi#1 for the kernel change and Patch raspberrypi#2 for enhanced selftest test_maps. ==================== Signed-off-by: Alexei Starovoitov <ast@kernel.org>
2 parents d2e614c + 9eca508 commit 3bcd604

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

‎kernel/bpf/map_in_map.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ struct bpf_map *bpf_map_meta_alloc(int inner_map_ufd)
5858
inner_map_meta->value_size = inner_map->value_size;
5959
inner_map_meta->map_flags = inner_map->map_flags;
6060
inner_map_meta->max_entries = inner_map->max_entries;
61+
inner_map_meta->spin_lock_off = inner_map->spin_lock_off;
6162

6263
/* Misc members not needed in bpf_map_meta_equal() check. */
6364
inner_map_meta->ops = inner_map->ops;

‎tools/testing/selftests/bpf/progs/test_map_in_map.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ SEC("xdp_mimtest")
2727
int xdp_mimtest0(struct xdp_md *ctx)
2828
{
2929
int value = 123;
30+
int *value_p;
3031
int key = 0;
3132
void *map;
3233

@@ -35,6 +36,9 @@ int xdp_mimtest0(struct xdp_md *ctx)
3536
return XDP_DROP;
3637

3738
bpf_map_update_elem(map, &key, &value, 0);
39+
value_p = bpf_map_lookup_elem(map, &key);
40+
if (!value_p || *value_p != 123)
41+
return XDP_DROP;
3842

3943
map = bpf_map_lookup_elem(&mim_hash, &key);
4044
if (!map)

0 commit comments

Comments
 (0)