selftests/bpf: Add a failure test for bpf_kptr_xchg() with local kptr
authorYonghong Song <yonghong.song@linux.dev>
Tue, 22 Aug 2023 05:00:58 +0000 (22:00 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 22 Aug 2023 16:43:55 +0000 (09:43 -0700)
commitfb30159426439bfe9a1435c0555f67201198988c
tree4acd7a9740f051b508787db0c6cf7d10bffb7ff2
parentab6c637ad0276e42f8acabcbc64932a6d346dab3
selftests/bpf: Add a failure test for bpf_kptr_xchg() with local kptr

For a bpf_kptr_xchg() with local kptr, if the map value kptr type and
allocated local obj type does not match, with the previous patch,
the below verifier error message will be logged:
  R2 is of type <allocated local obj type> but <map value kptr type> is expected

Without the previous patch, the test will have unexpected success.

Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
Acked-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Link: https://lore.kernel.org/r/20230822050058.2887354-1-yonghong.song@linux.dev
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/prog_tests/local_kptr_stash.c
tools/testing/selftests/bpf/progs/local_kptr_stash_fail.c [new file with mode: 0644]