]> 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)
commit006e90ea6efb1fafe1008cb6cc169ac967d77eac
tree1e267745789439496f30a151536d621e1151389a
parent3677319cbfb6959c157bc5115d9bf086873fdf0a
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