aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/bpf/arraymap.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/bpf/arraymap.c')
-rw-r--r--kernel/bpf/arraymap.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/kernel/bpf/arraymap.c b/kernel/bpf/arraymap.c
index 217b10bd9f48..584636c9e2eb 100644
--- a/kernel/bpf/arraymap.c
+++ b/kernel/bpf/arraymap.c
@@ -391,7 +391,8 @@ static void array_map_seq_show_elem(struct bpf_map *map, void *key,
391 return; 391 return;
392 } 392 }
393 393
394 seq_printf(m, "%u: ", *(u32 *)key); 394 if (map->btf_key_type_id)
395 seq_printf(m, "%u: ", *(u32 *)key);
395 btf_type_seq_show(map->btf, map->btf_value_type_id, value, m); 396 btf_type_seq_show(map->btf, map->btf_value_type_id, value, m);
396 seq_puts(m, "\n"); 397 seq_puts(m, "\n");
397 398
@@ -428,6 +429,18 @@ static int array_map_check_btf(const struct bpf_map *map,
428{ 429{
429 u32 int_data; 430 u32 int_data;
430 431
432 /* One exception for keyless BTF: .bss/.data/.rodata map */
433 if (btf_type_is_void(key_type)) {
434 if (map->map_type != BPF_MAP_TYPE_ARRAY ||
435 map->max_entries != 1)
436 return -EINVAL;
437
438 if (BTF_INFO_KIND(value_type->info) != BTF_KIND_DATASEC)
439 return -EINVAL;
440
441 return 0;
442 }
443
431 if (BTF_INFO_KIND(key_type->info) != BTF_KIND_INT) 444 if (BTF_INFO_KIND(key_type->info) != BTF_KIND_INT)
432 return -EINVAL; 445 return -EINVAL;
433 446