selftests/bpf: add selftest validating callback result is enforced
authorAndrii Nakryiko <andrii@kernel.org>
Sat, 2 Dec 2023 17:56:59 +0000 (09:56 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Sat, 2 Dec 2023 19:36:50 +0000 (11:36 -0800)
commit60a6b2c78c62d0a99ccb7ad5edc950f79e56306a
tree79f713f33847013456174f352d42e936941bfb18
parent8fa4ecd49b81ccd9d1d87f1c8b2260e218644878
selftests/bpf: add selftest validating callback result is enforced

BPF verifier expects callback subprogs to return values from specified
range (typically [0, 1]). This requires that r0 at exit is both precise
(because we rely on specific value range) and is marked as read
(otherwise state comparison will ignore such register as unimportant).

Add a simple test that validates that all these conditions are enforced.

Acked-by: Eduard Zingerman <eddyz87@gmail.com>
Acked-by: Shung-Hsi Yu <shung-hsi.yu@suse.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/r/20231202175705.885270-6-andrii@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/progs/verifier_subprog_precision.c