An io_uring zero-copy RX ifq can be exported by one ring and imported by another. Both rings then perform receive-zc on their own TCP sockets, but they share the same struct io_zcrx_ifq and therefore the same ifq->notif_stats. The statistics update is not atomic: static void zcrx_stat_add(__u64 *p, s64 v) { WRITE_ONCE(*p, READ_ONCE(*p) + v); } io_uring/zcrx.c:1337-1340. It is called for copy_count and copy_bytes from io_zcrx_copy_frag() at zcrx.c:1770-1771. There is no ifq-level lock in this path. lock_sock() in io_zcrx_tcp_recvmsg() is per TCP socket, the ring's uring_lock is per ring, alloc_lock only protects fallback niov allocation and is released before the copy, and ctx_lock/notification is taken after the statistics update and is not involved when event_desc.type_mask == 0. Two CPUs can therefore read the same old value, add their own increments, and write back the same new value: one update is lost. The effect is limited to the UAPI cumulative copy statistics (struct zcrx_stats at include/uapi/linux/io_uring/zcrx.h:83-86). The values are user-mappable diagnostic data; the race does not control buffer lifetime, DMA, reference counts, or packet contents. The detailed description: * Test environment / affected version Linux 7.3.0 (gcc 13.3.0, GNU ld 2.42) #6 SMP PREEMPT_DYNAMIC, vanilla mainline 7.3, x86_64 QEMU/KVM guest, 8 vCPUs, 4 GiB, CONFIG_KASAN=y. The tested io_uring/zcrx.c is byte-identical to v7.3: SHA-256 6e4e9828c84179b7a1877f0f843cc230f865d42665cbd0d43441493c67c70980. The kernel was not modified; no delay or other amplification was inserted. bzImage SHA-256: cdc1122bc0bdd2c65f92650bef919ff7b1f15d42bf64e3b0b079352fccf7b104. Relevant config includes CONFIG_IO_URING=y, CONFIG_IO_URING_ZCRX=y and CONFIG_KASAN=y. * Mechanism Shared object and two writers: - Ring A registers a ZCRX_REG_NODEV ifq with a user-memory area and a stats-only event descriptor: event_desc.flags = ZCRX_EVENT_DESC_FLAG_STATS and event_desc.type_mask = 0. The stats pointer is validated and stored at zcrx.c:935-960 (pointer at 956, memset at 957). Because type_mask is zero, zcrx_set_ring_ctx() is not called (zcrx.c:1092-1093) and master_ctx is NULL; this is valid and statistics still update. - A exports the ifq with ZCRX_CTRL_EXPORT. zcrx_export() checks that the control fields are zero and increments refs and user_refs at zcrx.c:805-806, attaches the original ifq to the [zcrx] file at 808-809, and installs an fd. - Ring B imports the same ifq with ZCRX_REG_IMPORT. import_zcrx() requires DEFER_TASKRUN plus CQE32 or CQE_MIXED, rejects nonzero if_rxq/rq_entries/area_ptr/region_ptr/event_desc, takes the same ifq at zcrx.c:861, increments refs/user_refs at 862-863, and stores it in B's xarray at 880. - A and B each submit a multishot IORING_OP_RECV_ZC on a different TCP socket. A's and B's recv paths can execute io_zcrx_copy_frag() concurrently. The missing serialization: - zcrx_stat_add() is a plain load-add-store, not an atomic RMW. - lock_sock(sk) at zcrx.c:1927 only serializes operations on one socket; A and B use different sockets. - uring_lock is per ring and does not cross rings. - alloc_lock at zcrx.c:1663 only covers io_alloc_fallback_niov(); it is not held during the copy or the statistics update. - ctx_lock at zcrx.c:1351 protects notification state and master_ctx, is taken after the statistics update, and is not reached at all for type_mask == 0. - no pp_lock or rq.lock is held by the copy path. Minimal interleaving for one field: CPU 0: read copy_bytes == V CPU 1: read copy_bytes == V CPU 0: write V + len0 CPU 1: write V + len1 (len0 is lost) copy_count has the same pattern with v = 1. The final values can be lower than the number/bytes of data CQEs actually delivered, and the two fields can be mutually inconsistent. The paged-fragment requirement is important: the linear skb head is handled by io_zcrx_copy_chunk() (zcrx.c:1710-1758) and does not update stats. A non-net_iov paged fragment enters io_zcrx_copy_frag() through io_zcrx_recv_frag() at zcrx.c:1785-1786, which is where zcrx_stat_add() is called. A pure linear send may therefore produce CQEs without exercising the race. * Trigger model Requirements: 1. Two rings, each created with DEFER_TASKRUN, SINGLE_ISSUER and CQE32 or CQE_MIXED (the io_uring_setup requirement for DEFER_TASKRUN is in io_uring/io_uring.c:2832-2833). 2. Ring A has a stat-enabled NODEV ifq with a user-memory area and a valid stats_offset; event_desc.type_mask may be zero. 3. A exports the ifq and B imports it, so both use the same ifq and the same notif_stats address. 4. A and B receive on different TCP sockets (different lock_sock instances). 5. Paged non-net_iov skb fragments enter io_zcrx_copy_frag(); a sendfile()/splice/MSG_ZEROCOPY style sender on loopback is sufficient in the reproducer. 6. The two updates overlap in the load-add-store window. No special hardware is needed for the NODEV path; a loopback TCP pair is enough. The existing reproducer uses two independent loopback connections and two sender threads. * Reproducer (attached: zcrx_verify.c) and results on 7.3 zcrx_verify.c is a self-contained raw-syscall program; no liburing is required. It creates two rings A/B, registers the NODEV ifq on A, exports it, imports it on B, drives one multishot IORING_OP_RECV_ZC per ring, returns each data CQE's rcqe->off as an RQE, and calls IORING_REGISTER_ZCRX_CTRL with ZCRX_CTRL_FLUSH_RQ on the owning ring. FLUSH_RQ is required on the NODEV path: there is no page_pool automatic refill, so without it the area is exhausted and the run stops. FLUSH_RQ must be issued by the thread that owns the ring (otherwise the kernel returns -EEXIST). Build: gcc -static -O2 -g -pthread -Wall -Wextra \ -Ilinux-7.3/include/uapi -Ilinux-7.3/include \ -o zcrx_verify zcrx_verify.c Run: boot the 7.3 KASAN bzImage under QEMU/KVM with a custom initramfs whose /init runs /zcrx_verify, with 8 vCPUs and 4 GiB. The program takes the run time in seconds as its argument. The dual-ring log was captured with a 0-error clean run; SINGLE=1 runs the same binary with only ring A as a control. Results (unmodified v7.3, no test delay): single ring, zcrx-single3.log: data_cqes = 223000, data_bytes = 859635712 copy_count = 223000, copy_bytes = 859635712 delta_count = 0, delta_bytes = 0 dual ring, zcrx-final-clean.log (0 error CQEs): data_cqes = 76888, data_bytes = 296353792 copy_count = 76863, copy_bytes = 296243359 delta_count = -25, delta_bytes = -110433 additional dual-ring trials: -8245 bytes / -3 count, -24470 bytes / -6 count, -77824 bytes / -17 count The single-ring control is exact at 223,000 CQEs / 859 MB, so the accounting convention is consistent and there is no systemic linear-head or CQ-loss bias in this test. The dual-ring runs are consistently negative; the clean run has zero error CQEs and still loses 110,433 bytes and 25 count increments. copy_count counts per-fragment updates while the data CQE count is per completed buffer, so the count delta is not expected to be numerically equal to the CQE delta; copy_bytes is the primary signal. No KASAN report, WARN or Oops was observed. * Suggested direction Serialize the two updates per ifq, e.g. add a spinlock_t stats_lock to struct io_zcrx_ifq, initialize it in io_zcrx_ifq_alloc(), and hold it around both zcrx_stat_add() calls in io_zcrx_copy_frag(), releasing it before zcrx_send_notif(). A lockless alternative is to keep private atomic64 counters and publish a consistent snapshot, or to document the fields as best-effort. READ_ONCE()/WRITE_ONCE() alone do not make the read-modify-write atomic and do not fix the lost update. Please keep me in Cc; I am not subscribed to the lists. Regards, Hanxiang Xu xuhx@hust.edu.cn