Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 14efbe24 authored by Quentin Monnet's avatar Quentin Monnet Committed by Greg Kroah-Hartman
Browse files

bpftool: Fix bug for long instructions in program CFG dumps



[ Upstream commit 67cf52cdb6c8fa6365d29106555dacf95c9fd374 ]

When dumping the control flow graphs for programs using the 16-byte long
load instruction, we need to skip the second part of this instruction
when looking for the next instruction to process. Otherwise, we end up
printing "BUG_ld_00" from the kernel disassembler in the CFG.

Fixes: efcef17a ("tools: bpftool: generate .dot graph from CFG information")
Signed-off-by: default avatarQuentin Monnet <quentin@isovalent.com>
Link: https://lore.kernel.org/r/20230405132120.59886-3-quentin@isovalent.com


Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 3e3533c5
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -363,8 +363,15 @@ void dump_xlated_for_graph(struct dump_data *dd, void *buf_start, void *buf_end,
	struct bpf_insn *insn_start = buf_start;
	struct bpf_insn *insn_end = buf_end;
	struct bpf_insn *cur = insn_start;
	bool double_insn = false;

	for (; cur <= insn_end; cur++) {
		if (double_insn) {
			double_insn = false;
			continue;
		}
		double_insn = cur->code == (BPF_LD | BPF_IMM | BPF_DW);

		printf("% 4d: ", (int)(cur - insn_start + start_idx));
		print_bpf_insn(&cbs, cur, true);
		if (cur != insn_end)