]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
selftests/bpf: Add torn write detection test for htab BPF_F_LOCK
authorMykyta Yatsenko <yatsenko@meta.com>
Wed, 1 Apr 2026 13:50:37 +0000 (06:50 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Mon, 6 Apr 2026 01:37:32 +0000 (18:37 -0700)
commitf64eb44ce9067d37e6334a940518dcf1254e83fe
tree151644c9a12e571bd9257619b9cbd4fb1774506c
parent07738bc566c38e0a8c82084e962890d1d59715c8
selftests/bpf: Add torn write detection test for htab BPF_F_LOCK

Add a consistency subtest to htab_reuse that detects torn writes
caused by the BPF_F_LOCK lockless update racing with element
reallocation in alloc_htab_elem().

The test uses three thread roles started simultaneously via a pipe:
 - locked updaters: BPF_F_LOCK|BPF_EXIST in-place updates
 - delete+update workers: delete then BPF_ANY|BPF_F_LOCK insert
 - locked readers: BPF_F_LOCK lookup checking value consistency

Signed-off-by: Mykyta Yatsenko <yatsenko@meta.com>
Link: https://lore.kernel.org/r/20260401-bpf_map_torn_writes-v1-2-782d071c55e7@meta.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/prog_tests/htab_reuse.c
tools/testing/selftests/bpf/progs/htab_reuse.c