diff options
| author | Toke Høiland-Jørgensen <[email protected]> | 2020-02-06 10:29:06 +0000 |
|---|---|---|
| committer | Daniel Borkmann <[email protected]> | 2020-02-07 21:29:45 +0000 |
| commit | d95f1e8b462c4372ac409886070bb8719d8a4d3a (patch) | |
| tree | 51b5933cf72754517120706d152f3205285512f3 /tools/bpf/bpftool/prog.c | |
| parent | bpf, sockmap: Check update requirements after locking (diff) | |
| download | kernel-d95f1e8b462c4372ac409886070bb8719d8a4d3a.tar.gz kernel-d95f1e8b462c4372ac409886070bb8719d8a4d3a.zip | |
bpftool: Don't crash on missing xlated program instructions
Turns out the xlated program instructions can also be missing if
kptr_restrict sysctl is set. This means that the previous fix to check the
jited_prog_insns pointer was insufficient; add another check of the
xlated_prog_insns pointer as well.
Fixes: 5b79bcdf0362 ("bpftool: Don't crash on missing jited insns or ksyms")
Fixes: cae73f233923 ("bpftool: use bpf_program__get_prog_info_linear() in prog.c:do_dump()")
Signed-off-by: Toke Høiland-Jørgensen <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
Reviewed-by: Quentin Monnet <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
Diffstat (limited to 'tools/bpf/bpftool/prog.c')
| -rw-r--r-- | tools/bpf/bpftool/prog.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c index a3521deca869..b352ab041160 100644 --- a/tools/bpf/bpftool/prog.c +++ b/tools/bpf/bpftool/prog.c @@ -536,7 +536,7 @@ prog_dump(struct bpf_prog_info *info, enum dump_mode mode, buf = (unsigned char *)(info->jited_prog_insns); member_len = info->jited_prog_len; } else { /* DUMP_XLATED */ - if (info->xlated_prog_len == 0) { + if (info->xlated_prog_len == 0 || !info->xlated_prog_insns) { p_err("error retrieving insn dump: kernel.kptr_restrict set?"); return -1; } |
