Skip to content

Commit 8e5644c

Browse files
eddyz87gregkh
authored andcommitted
bpf: handle jset (if a & b ...) as a jump in CFG computation
[ Upstream commit 3157f7e ] BPF_JSET is a conditional jump and currently verifier.c:can_jump() does not know about that. This can lead to incorrect live registers and SCC computation. E.g. in the following example: 1: r0 = 1; 2: r2 = 2; 3: if r1 & 0x7 goto +1; 4: exit; 5: r0 = r2; 6: exit; W/o this fix insn_successors(3) will return only (4), a jump to (5) would be missed and r2 won't be marked as alive at (3). Fixes: 14c8552 ("bpf: simple DFA-based live registers analysis") Reported-by: [email protected] Suggested-by: Alexei Starovoitov <[email protected]> Signed-off-by: Eduard Zingerman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent b2ac701 commit 8e5644c

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

kernel/bpf/verifier.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23671,6 +23671,7 @@ static bool can_jump(struct bpf_insn *insn)
2367123671
case BPF_JSLT:
2367223672
case BPF_JSLE:
2367323673
case BPF_JCOND:
23674+
case BPF_JSET:
2367423675
return true;
2367523676
}
2367623677

0 commit comments

Comments
 (0)