bpftool: Don't crash on missing xlated program instructions
authorToke Høiland-Jørgensen <toke@redhat.com>
Thu, 6 Feb 2020 10:29:06 +0000 (11:29 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 14 Feb 2020 21:34:09 +0000 (16:34 -0500)
commit1dfc34bd009a49367c56e174e9205a16e9f36752
treef27fea363606692bd8c802ac607e31832ee131fd
parentec81471a70d100fed872f3f25e069e51afb356c4
bpftool: Don't crash on missing xlated program instructions

commit d95f1e8b462c4372ac409886070bb8719d8a4d3a upstream.

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 <toke@redhat.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Reviewed-by: Quentin Monnet <quentin@isovalent.com>
Link: https://lore.kernel.org/bpf/20200206102906.112551-1-toke@redhat.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
tools/bpf/bpftool/prog.c