aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorAndrii Nakryiko <andriin@fb.com>2019-10-28 16:37:27 -0700
committerAlexei Starovoitov <ast@kernel.org>2019-10-28 20:27:40 -0700
commitd3a3aa0c59e83d8c13a758128b10dd459ce0d866 (patch)
tree6e1c65a50ad5b55da720c90c28eb1b56301b8149 /tools
parentlibbpf: Fix compatibility for kernels without need_wakeup (diff)
downloadlinux-dev-d3a3aa0c59e83d8c13a758128b10dd459ce0d866.tar.xz
linux-dev-d3a3aa0c59e83d8c13a758128b10dd459ce0d866.zip
libbpf: Fix off-by-one error in ELF sanity check
libbpf's bpf_object__elf_collect() does simple sanity check after iterating over all ELF sections, if checks that .strtab index is correct. Unfortunately, due to section indices being 1-based, the check breaks for cases when .strtab ends up being the very last section in ELF. Fixes: 77ba9a5b48a7 ("tools lib bpf: Fetch map names from correct strtab") Signed-off-by: Andrii Nakryiko <andriin@fb.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/20191028233727.1286699-1-andriin@fb.com
Diffstat (limited to 'tools')
-rw-r--r--tools/lib/bpf/libbpf.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index d71631a01926..5d15cc4dfcd6 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -1664,7 +1664,7 @@ static int bpf_object__elf_collect(struct bpf_object *obj, bool relaxed_maps)
}
}
- if (!obj->efile.strtabidx || obj->efile.strtabidx >= idx) {
+ if (!obj->efile.strtabidx || obj->efile.strtabidx > idx) {
pr_warn("Corrupted ELF file: index of strtab invalid\n");
return -LIBBPF_ERRNO__FORMAT;
}