Skip to content

Commit d95f1e8

Browse files
tohojoborkmann
authored andcommitted
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: 5b79bcd ("bpftool: Don't crash on missing jited insns or ksyms") Fixes: cae73f2 ("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]
1 parent 85b8ac0 commit d95f1e8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/bpf/bpftool/prog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ prog_dump(struct bpf_prog_info *info, enum dump_mode mode,
536536
buf = (unsigned char *)(info->jited_prog_insns);
537537
member_len = info->jited_prog_len;
538538
} else { /* DUMP_XLATED */
539-
if (info->xlated_prog_len == 0) {
539+
if (info->xlated_prog_len == 0 || !info->xlated_prog_insns) {
540540
p_err("error retrieving insn dump: kernel.kptr_restrict set?");
541541
return -1;
542542
}

0 commit comments

Comments
 (0)