diff options
author | Andrii Nakryiko <andriin@fb.com> | 2019-05-29 10:36:06 -0700 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2019-05-30 01:23:35 +0200 |
commit | c51829bb6e921337014d9ac3712b0b7e8cae9f3d (patch) | |
tree | 1a9122446bc71afbd93f72347f511212a800621c /tools/lib | |
parent | 12ef5634a855eb642b4d28781526fbd830aa7f7a (diff) | |
download | linux-c51829bb6e921337014d9ac3712b0b7e8cae9f3d.tar.gz linux-c51829bb6e921337014d9ac3712b0b7e8cae9f3d.tar.bz2 linux-c51829bb6e921337014d9ac3712b0b7e8cae9f3d.zip |
libbpf: check map name retrieved from ELF
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>
Diffstat (limited to 'tools/lib')
-rw-r--r-- | tools/lib/bpf/libbpf.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index fb296eadc3f2..60ec9694923a 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c @@ -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; |