selftests/bpf: Add local kptr stashing test
authorDave Marchevsky <davemarchevsky@fb.com>
Fri, 10 Mar 2023 23:07:43 +0000 (15:07 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Sat, 11 Mar 2023 00:38:05 +0000 (16:38 -0800)
commit5d8d6634cccf1ebd0db4e220e52e7128b030c7b4
tree4ec6a9eae1a29c21cf9b5f1d463d61299199948e
parent738c96d5e2e3700b370f02ac84a9dc159ca81f25
selftests/bpf: Add local kptr stashing test

Add a new selftest, local_kptr_stash, which uses bpf_kptr_xchg to stash
a bpf_obj_new-allocated object in a map. Test the following scenarios:

  * Stash two rb_nodes in an arraymap, don't unstash them, rely on map
    free to destruct them
  * Stash two rb_nodes in an arraymap, unstash the second one in a
    separate program, rely on map free to destruct first

Signed-off-by: Dave Marchevsky <davemarchevsky@fb.com>
Link: https://lore.kernel.org/r/20230310230743.2320707-4-davemarchevsky@fb.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/prog_tests/local_kptr_stash.c [new file with mode: 0644]
tools/testing/selftests/bpf/progs/local_kptr_stash.c [new file with mode: 0644]