]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Hoist type checking for nullable arg types
authorLorenz Bauer <lmb@cloudflare.com>
Mon, 21 Sep 2020 12:12:26 +0000 (13:12 +0100)
committerAlexei Starovoitov <ast@kernel.org>
Mon, 21 Sep 2020 22:00:41 +0000 (15:00 -0700)
commit47a82136a6774ac10035a9a0db6840fcf0c4dae4
tree1e267745789439496f30a151536d621e1151389a
parent8e55415632e59b7b1d76797cb440a8d40049dc9f
bpf: Hoist type checking for nullable arg types

check_func_arg has a plethora of weird if statements with empty branches.
They work around the fact that *_OR_NULL argument types should accept a
SCALAR_VALUE register, as long as it's value is 0. These statements make
it difficult to reason about the type checking logic.

Instead, skip more detailed type checking logic iff the register is 0,
and the function expects a nullable type. This allows simplifying the type
checking itself.

Signed-off-by: Lorenz Bauer <lmb@cloudflare.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Link: https://lore.kernel.org/bpf/20200921121227.255763-11-lmb@cloudflare.com
kernel/bpf/verifier.c