提交 c51829bb 编写于 作者: A Andrii Nakryiko 提交者: Daniel Borkmann

libbpf: check map name retrieved from ELF

Validate there was no error retrieving symbol name corresponding to
a BPF map.
Acked-by: NSong Liu <songliubraving@fb.com>
Signed-off-by: NAndrii Nakryiko <andriin@fb.com>
Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
上级 12ef5634
...@@ -920,6 +920,11 @@ bpf_object__init_maps(struct bpf_object *obj, int flags) ...@@ -920,6 +920,11 @@ bpf_object__init_maps(struct bpf_object *obj, int flags)
map_name = elf_strptr(obj->efile.elf, map_name = elf_strptr(obj->efile.elf,
obj->efile.strtabidx, obj->efile.strtabidx,
sym.st_name); 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].libbpf_type = LIBBPF_MAP_UNSPEC;
obj->maps[map_idx].offset = sym.st_value; obj->maps[map_idx].offset = sym.st_value;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册