]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
selftests/bpf: Add tests for special fields races
authorKumar Kartikeya Dwivedi <memxor@gmail.com>
Fri, 27 Feb 2026 22:48:05 +0000 (14:48 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 27 Feb 2026 23:39:00 +0000 (15:39 -0800)
commit2939d7b3b0e5f35359ce8f69dbbad0bfc4e920b6
tree9d89fe95ffee4efc17eef99084b39ba515d3ae80
parentbaa35b3cb6b642b903162aacff13181e170c4ecc
selftests/bpf: Add tests for special fields races

Add a couple of tests to ensure that the refcount drops to zero when we
exercise the race where creation of a special field succeeds the logical
bpf_obj_free_fields done when deleting an element. Prior to previous
changes, the fields would be freed eagerly and repopulate and end up
leaking, causing the reference to not drop down correctly. Running this
test on a kernel without fixes will cause a hang in delete_module, since
the module reference stays active due to the leaked kptr not dropping
it. After the fixes tests succeed as expected.

Reviewed-by: Amery Hung <ameryhung@gmail.com>
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Link: https://lore.kernel.org/r/20260227224806.646888-6-memxor@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/prog_tests/map_kptr_race.c [new file with mode: 0644]
tools/testing/selftests/bpf/progs/map_kptr_race.c [new file with mode: 0644]