selftests/bpf: Add test for prealloc_lru_pop bug
authorKumar Kartikeya Dwivedi <memxor@gmail.com>
Tue, 9 Aug 2022 21:30:33 +0000 (23:30 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 10 Aug 2022 01:46:11 +0000 (18:46 -0700)
commitde7b9927105bd2afe940c6ad22de6938edd8b1c1
tree8b2a5de71b7b3f5cdbc9972a27724030ea1010d2
parent275c30bcee66a27d1aa97a215d607ad6d49804cb
selftests/bpf: Add test for prealloc_lru_pop bug

Add a regression test to check against invalid check_and_init_map_value
call inside prealloc_lru_pop.

The kptr should not be reset to NULL once we set it after deleting the
map element. Hence, we trigger a program that updates the element
causing its reuse, and checks whether the unref kptr is reset or not.
If it is, prealloc_lru_pop does an incorrect check_and_init_map_value
call and the test fails.

Acked-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Link: https://lore.kernel.org/r/20220809213033.24147-4-memxor@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/prog_tests/lru_bug.c [new file with mode: 0644]
tools/testing/selftests/bpf/progs/lru_bug.c [new file with mode: 0644]