bpf: generalize is_scalar_branch_taken() logic
authorAndrii Nakryiko <andrii@kernel.org>
Sun, 12 Nov 2023 01:05:58 +0000 (17:05 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 15 Nov 2023 20:03:41 +0000 (12:03 -0800)
commit96381879a370425a30b810906946f64c0726450e
tree39e967f766aef108d7709c951218a98a7bd5dbbb
parent67420501e8681ae18f9f0ea0a69cd2f432100e70
bpf: generalize is_scalar_branch_taken() logic

Generalize is_branch_taken logic for SCALAR_VALUE register to handle
cases when both registers are not constants. Previously supported
<range> vs <scalar> cases are a natural subset of more generic <range>
vs <range> set of cases.

Generalized logic relies on straightforward segment intersection checks.

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/20231112010609.848406-3-andrii@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/verifier.c