OSDN Git Service

selftests/bpf: Add refcounted_kptr tests
authorDave Marchevsky <davemarchevsky@fb.com>
Sat, 15 Apr 2023 20:18:11 +0000 (13:18 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Sun, 16 Apr 2023 00:36:50 +0000 (17:36 -0700)
commit6147f15131e2df544a5449815f456da48c0c88e7
tree94d7c2b79cf60f0aecafab0fe209008a27957d44
parent3e81740a90626024a9d9c6f9bfa3d36204dafefb
selftests/bpf: Add refcounted_kptr tests

Test refcounted local kptr functionality added in previous patches in
the series.

Usecases which pass verification:

* Add refcounted local kptr to both tree and list. Then, read and -
  possibly, depending on test variant - delete from tree, then list.
  * Also test doing read-and-maybe-delete in opposite order
* Stash a refcounted local kptr in a map_value, then add it to a
  rbtree. Read from both, possibly deleting after tree read.
* Add refcounted local kptr to both tree and list. Then, try reading and
  deleting twice from one of the collections.
* bpf_refcount_acquire of just-added non-owning ref should work, as
  should bpf_refcount_acquire of owning ref just out of bpf_obj_new

Usecases which fail verification:

* The simple successful bpf_refcount_acquire cases from above should
  both fail to verify if the newly-acquired owning ref is not dropped

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