bpf: generalize is_branch_taken() to work with two registers
authorAndrii Nakryiko <andrii@kernel.org>
Thu, 2 Nov 2023 03:37:54 +0000 (20:37 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 10 Nov 2023 02:58:39 +0000 (18:58 -0800)
commitc31534267c180f7ed00288d239a501b554885300
treea3ff31f785879c916863516a1f7aac825c2b9af3
parentc2a3ab094683ddc154879a1364fc7cb0228f96a6
bpf: generalize is_branch_taken() to work with two registers

While still assuming that second register is a constant, generalize
is_branch_taken-related code to accept two registers instead of register
plus explicit constant value. This also, as a side effect, allows to
simplify check_cond_jmp_op() by unifying BPF_K case with BPF_X case, for
which we use a fake register to represent BPF_K's imm constant as
a register.

Acked-by: Eduard Zingerman <eddyz87@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Shung-Hsi Yu <shung-hsi.yu@suse.com>
Link: https://lore.kernel.org/r/20231102033759.2541186-13-andrii@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/verifier.c