bpf: Prepare prog_test_struct kfuncs for runtime tests
authorKumar Kartikeya Dwivedi <memxor@gmail.com>
Wed, 11 May 2022 19:46:52 +0000 (01:16 +0530)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 11 May 2022 23:57:27 +0000 (16:57 -0700)
commit5cdccadcac2612f947ebc26ad7023dfb7e8871f9
tree73e7ec42e6a391e7263b476569eea5b35f97ca93
parent5b74c690e1c55953ec99fd9dab74f72dbee4fe95
bpf: Prepare prog_test_struct kfuncs for runtime tests

In an effort to actually test the refcounting logic at runtime, add a
refcount_t member to prog_test_ref_kfunc and use it in selftests to
verify and test the whole logic more exhaustively.

The kfunc calls for prog_test_member do not require runtime refcounting,
as they are only used for verifier selftests, not during runtime
execution. Hence, their implementation now has a WARN_ON_ONCE as it is
not meant to be reachable code at runtime. It is strictly used in tests
triggering failure cases in the verifier. bpf_kfunc_call_memb_release is
called from map free path, since prog_test_member is embedded in map
value for some verifier tests, so we skip WARN_ON_ONCE for it.

Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Link: https://lore.kernel.org/r/20220511194654.765705-3-memxor@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
net/bpf/test_run.c
tools/testing/selftests/bpf/verifier/map_kptr.c