bpf: selftest: Ensure the return value of the bpf_per_cpu_ptr() must be checked
authorMartin KaFai Lau <kafai@fb.com>
Mon, 19 Oct 2020 19:42:25 +0000 (12:42 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Mon, 19 Oct 2020 22:57:42 +0000 (15:57 -0700)
commit8568c3cefd5143fa0dc09f90e1bc9dc8905292f4
tree90ff2079a7ea6260ffe6399e1d00f457cabea8cf
parente710bcc6d92c47bb7d8e803b41ef529c09ad6a9e
bpf: selftest: Ensure the return value of the bpf_per_cpu_ptr() must be checked

This patch tests all pointers returned by bpf_per_cpu_ptr() must be
tested for NULL first before it can be accessed.

This patch adds a subtest "null_check", so it moves the ".data..percpu"
existence check to the very beginning and before doing any subtest.

Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20201019194225.1051596-1-kafai@fb.com
tools/testing/selftests/bpf/prog_tests/ksyms_btf.c
tools/testing/selftests/bpf/progs/test_ksyms_btf_null_check.c [new file with mode: 0644]