bpf: reuse subprog argument parsing logic for subprog call checks
authorAndrii Nakryiko <andrii@kernel.org>
Fri, 15 Dec 2023 01:13:29 +0000 (17:13 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 20 Dec 2023 02:06:46 +0000 (18:06 -0800)
commitf18c3d88deedf0defc3e4800341cc7bcaaabcdf9
treed57714bbf760073e1542452360d88ebc854d443b
parentc5a7244759b1eeacc59d0426fb73859afa942d0d
bpf: reuse subprog argument parsing logic for subprog call checks

Remove duplicated BTF parsing logic when it comes to subprog call check.
Instead, use (potentially cached) results of btf_prepare_func_args() to
abstract away expectations of each subprog argument in generic terms
(e.g., "this is pointer to context", or "this is a pointer to memory of
size X"), and then use those simple high-level argument type
expectations to validate actual register states to check if they match
expectations.

Acked-by: Eduard Zingerman <eddyz87@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/r/20231215011334.2307144-6-andrii@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/verifier.c
tools/testing/selftests/bpf/progs/test_global_func5.c