diff options
author | Kumar Kartikeya Dwivedi <memxor@gmail.com> | 2022-12-08 02:11:41 +0530 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2022-12-08 18:39:28 -0800 |
commit | 292064cce7969787f13ed9988733aadc12fe0ca2 (patch) | |
tree | c4c5bf3a1aca49f5d0d4e60c91af777e0a3634bf /tools/testing/selftests/bpf/prog_tests/user_ringbuf.c | |
parent | bpf: Use memmove for bpf_dynptr_{read,write} (diff) | |
download | linux-292064cce7969787f13ed9988733aadc12fe0ca2.tar.gz linux-292064cce7969787f13ed9988733aadc12fe0ca2.tar.bz2 linux-292064cce7969787f13ed9988733aadc12fe0ca2.zip |
selftests/bpf: Add test for dynptr reinit in user_ringbuf callback
The original support for bpf_user_ringbuf_drain callbacks simply
short-circuited checks for the dynptr state, allowing users to pass
PTR_TO_DYNPTR (now CONST_PTR_TO_DYNPTR) to helpers that initialize a
dynptr. This bug would have also surfaced with other dynptr helpers in
the future that changed dynptr view or modified it in some way.
Include test cases for all cases, i.e. both bpf_dynptr_from_mem and
bpf_ringbuf_reserve_dynptr, and ensure verifier rejects both of them.
Without the fix, both of these programs load and pass verification.
While at it, remove sys_nanosleep target from failure cases' SEC
definition, as there is no such tracepoint.
Acked-by: David Vernet <void@manifault.com>
Acked-by: Joanne Koong <joannelkoong@gmail.com>
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Link: https://lore.kernel.org/r/20221207204141.308952-8-memxor@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests/user_ringbuf.c')
-rw-r--r-- | tools/testing/selftests/bpf/prog_tests/user_ringbuf.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/prog_tests/user_ringbuf.c b/tools/testing/selftests/bpf/prog_tests/user_ringbuf.c index aefa0a474e58..dae68de285b9 100644 --- a/tools/testing/selftests/bpf/prog_tests/user_ringbuf.c +++ b/tools/testing/selftests/bpf/prog_tests/user_ringbuf.c @@ -676,6 +676,8 @@ static struct { {"user_ringbuf_callback_discard_dynptr", "cannot release unowned const bpf_dynptr"}, {"user_ringbuf_callback_submit_dynptr", "cannot release unowned const bpf_dynptr"}, {"user_ringbuf_callback_invalid_return", "At callback return the register R0 has value"}, + {"user_ringbuf_callback_reinit_dynptr_mem", "Dynptr has to be an uninitialized dynptr"}, + {"user_ringbuf_callback_reinit_dynptr_ringbuf", "Dynptr has to be an uninitialized dynptr"}, }; #define SUCCESS_TEST(_func) { _func, #_func } |