When booting a Qemu VM with virtio-blk and KCSAN enabled, KCSAN emits the following warning about a data-race in virtqueue_kick_prepare().
================================================================== BUG: KCSAN: data-race in virtqueue_kick_prepare+0x14d/0x200 race at unknown origin, with read to 0xffff888101c9cd44 of 2 bytes by task 224 on cpu 2: virtqueue_kick_prepare+0x14d/0x200 virtio_fs_enqueue_req+0x664/0x7d0 virtio_fs_send_req+0xac/0x230 flush_bg_queue+0x1a8/0x1f0 fuse_simple_background+0x312/0x490 fuse_file_put+0xcf/0x190 fuse_file_release+0xd3/0xf0 fuse_release+0x91/0xb0 __fput+0x200/0x4f0 ____fput+0x15/0x20 task_work_run+0xda/0x140 do_exit+0x414/0x11a0 do_group_exit+0x53/0xf0 __x64_sys_exit_group+0x25/0x30 x64_sys_call+0x1c23/0x1c30 do_syscall_64+0x5d/0x240 entry_SYSCALL_64_after_hwframe+0x76/0x7e value changed: 0x1ab0 -> 0x1ab3 Reported by Kernel Concurrency Sanitizer on: CPU: 2 UID: 0 PID: 224 Comm: grepconf.sh Not tainted 6.19.0-rc7+ #230 PREEMPT(none) Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.17.0-9.fc43 06/10/2025 ================================================================== This warning is likely a false positive as the change happens on the virtio vring. Annotate the return of vring_avail_event() with data_race() to silence the warning. Signed-off-by: Johannes Thumshirn <[email protected]> --- include/uapi/linux/virtio_ring.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/uapi/linux/virtio_ring.h b/include/uapi/linux/virtio_ring.h index f8c20d3de8da..32568cfa1c63 100644 --- a/include/uapi/linux/virtio_ring.h +++ b/include/uapi/linux/virtio_ring.h @@ -194,7 +194,7 @@ struct vring { /* We publish the used event index at the end of the available ring, and vice * versa. They are at the end for backwards compatibility. */ #define vring_used_event(vr) ((vr)->avail->ring[(vr)->num]) -#define vring_avail_event(vr) (*(__virtio16 *)&(vr)->used->ring[(vr)->num]) +#define vring_avail_event(vr) (data_race(*(__virtio16 *)&(vr)->used->ring[(vr)->num])) static inline void vring_init(struct vring *vr, unsigned int num, void *p, unsigned long align) -- 2.52.0

