diff options
author | Toke Høiland-Jørgensen <toke@redhat.com> | 2019-12-10 21:14:12 +0300 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2019-12-11 15:57:26 +0300 |
commit | 5b79bcdf03628a3a9ee04d9cd5fabcf61a8e20be (patch) | |
tree | c3f21a9c363b0b320e5678a69b1d847d733cb5ef /tools/bpf/bpftool/xlated_dumper.c | |
parent | 4c80c7bc583a87ded5f61906f81256b57c795806 (diff) | |
download | linux-5b79bcdf03628a3a9ee04d9cd5fabcf61a8e20be.tar.xz |
bpftool: Don't crash on missing jited insns or ksyms
When the kptr_restrict sysctl is set, the kernel can fail to return
jited_ksyms or jited_prog_insns, but still have positive values in
nr_jited_ksyms and jited_prog_len. This causes bpftool to crash when
trying to dump the program because it only checks the len fields not
the actual pointers to the instructions and ksyms.
Fix this by adding the missing checks.
Fixes: 71bb428fe2c1 ("tools: bpf: add bpftool")
Fixes: f84192ee00b7 ("tools: bpftool: resolve calls without using imm field")
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Link: https://lore.kernel.org/bpf/20191210181412.151226-1-toke@redhat.com
Diffstat (limited to 'tools/bpf/bpftool/xlated_dumper.c')
-rw-r--r-- | tools/bpf/bpftool/xlated_dumper.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/bpf/bpftool/xlated_dumper.c b/tools/bpf/bpftool/xlated_dumper.c index 494d7ae3614d..5b91ee65a080 100644 --- a/tools/bpf/bpftool/xlated_dumper.c +++ b/tools/bpf/bpftool/xlated_dumper.c @@ -174,7 +174,7 @@ static const char *print_call(void *private_data, struct kernel_sym *sym; if (insn->src_reg == BPF_PSEUDO_CALL && - (__u32) insn->imm < dd->nr_jited_ksyms) + (__u32) insn->imm < dd->nr_jited_ksyms && dd->jited_ksyms) address = dd->jited_ksyms[insn->imm]; sym = kernel_syms_search(dd, address); |