summaryrefslogtreecommitdiff
path: root/rust/kernel/alloc/kvec/errors.rs
diff options
context:
space:
mode:
authorNicholas Velten <nicholasfvelten@gmail.com>2026-10-19 14:38:20 -0300
committerAlexei Starovoitov <ast@kernel.org>2026-10-20 00:20:22 +0000
commitf25f6319e248034f3df83352e450ab3172eece43 (patch)
tree4dfbdbb62f2c36d03426c34e4c65765bcd72ee56 /rust/kernel/alloc/kvec/errors.rs
parent1907a7d0a1788ba794eff7e75cb140599bef34e2 (diff)
bpf: Annotate data races on bpf_lru_node type
KCSAN reports a data race on bpf_lru_node::type between the LRU list rotation and the free path of the common LRU: BUG: KCSAN: data-race in __bpf_lru_list_rotate / bpf_lru_push_free write to 0xffff88811b758022 of 1 bytes by task 4756 on cpu 1: __bpf_lru_node_move __bpf_lru_list_rotate_active __bpf_lru_list_rotate bpf_lru_list_pop_free_to_local bpf_common_lru_pop_free bpf_lru_pop_free htab_lru_map_update_elem read to 0xffff88811b758022 of 1 bytes by task 4752 on cpu 0: bpf_lru_list_push_free bpf_common_lru_push_free bpf_lru_push_free htab_lru_push_free htab_lru_map_update_elem value changed: 0x00 -> 0x01 bpf_lru_list_push_free() reads node->type for a WARN_ON_ONCE() sanity check before taking l->lock. __bpf_lru_node_move(), called right after under l->lock, does the same check, so drop the unlocked one. bpf_common_lru_push_free() re-checks node->type under loc_l->lock after the lockless READ_ONCE() at function entry. By then the node has been removed from the htab, so only flush and rotate can change its type, through __bpf_lru_node_move_in() and __bpf_lru_node_move() under l->lock. Mark that re-check with READ_ONCE() and those two writers with WRITE_ONCE(), following commit 6df8fb83301d ("bpf_lru_list: Read double-checked variable once without lock"). The remaining writers operate on a node with a single owner that nobody else reads and are left alone. Tested on bpf-next with CONFIG_KCSAN=y in a 4-vCPU virtme-ng guest, using a reproducer that runs 8 threads issuing BPF_MAP_UPDATE_BATCH on a 64-entry BPF_MAP_TYPE_LRU_HASH with overlapping keys. Reported-by: syzbot+1ea4f564bf6f1f3d1dc4@syzkaller.appspotmail.com Signed-off-by: Nicholas Velten <nicholasfvelten@gmail.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261019-fix-lru-node-type-kcsan-v2-1-c10a410b3565@gmail.com Closes: https://syzkaller.appspot.com/bug?extid=1ea4f564bf6f1f3d1dc4
Diffstat (limited to 'rust/kernel/alloc/kvec/errors.rs')
0 files changed, 0 insertions, 0 deletions