Skip to content

Commit defac89

Browse files
troglodytanakryiko
authored andcommitted
bpftool: Fix control flow graph segfault during edge creation
If the last instruction of a control flow graph building block is a BPF_CALL, an incorrect edge with e->dst set to NULL is created and results in a segfault during graph output. Ensure that BPF_CALL as last instruction of a building block is handled correctly and only generates a single edge unlike actual BPF_JUMP* instructions. Signed-off-by: Christoph Werle <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Tested-by: Quentin Monnet <[email protected]> Reviewed-by: Quentin Monnet <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent a43796b commit defac89

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

tools/bpf/bpftool/cfg.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ static bool func_add_bb_edges(struct func_node *func)
302302

303303
insn = bb->tail;
304304
if (!is_jmp_insn(insn->code) ||
305+
BPF_OP(insn->code) == BPF_CALL ||
305306
BPF_OP(insn->code) == BPF_EXIT) {
306307
e->dst = bb_next(bb);
307308
e->flags |= EDGE_FLAG_FALLTHROUGH;

0 commit comments

Comments
 (0)