]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
libbpf: check map name retrieved from ELF
authorAndrii Nakryiko <andriin@fb.com>
Wed, 29 May 2019 17:36:06 +0000 (10:36 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Wed, 29 May 2019 23:23:35 +0000 (01:23 +0200)
Validate there was no error retrieving symbol name corresponding to
a BPF map.

Acked-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
tools/lib/bpf/libbpf.c

index fb296eadc3f2871fd2966da7805ed521dccae640..60ec9694923a7a2dc1f6d3d9f500a1820f46a907 100644 (file)
@@ -920,6 +920,11 @@ bpf_object__init_maps(struct bpf_object *obj, int flags)
                map_name = elf_strptr(obj->efile.elf,
                                      obj->efile.strtabidx,
                                      sym.st_name);
+               if (!map_name) {
+                       pr_warning("failed to get map #%d name sym string for obj %s\n",
+                                  map_idx, obj->path);
+                       return -LIBBPF_ERRNO__FORMAT;
+               }
 
                obj->maps[map_idx].libbpf_type = LIBBPF_MAP_UNSPEC;
                obj->maps[map_idx].offset = sym.st_value;