KCSAN: data-race in io_issue_sqe / io_submit_sqes

Status: moderation: reported on 2026/11/17 10:12
Subsystems: io-uring
Labels: race:benign prio:low
[Documentation on labels]
Reported-by: syzbot+fbbda44f5390494292c2@syzkaller.appspotmail.com
First crash: 7h30m, last: 7h30m
✨ AI-generated root cause summary:

A KCSAN data race occurs between task submission and asynchronous io-wq request completion on the 32-bit field ctx->int_flags. In io_init_req() (called from io_submit_sqes() by the submission task or SQPOLL thread under ctx->uring_lock), handling IOSQE_CQE_SKIP_SUCCESS executes an unmarked plain C read-modify-write ctx->int_flags |= IO_RING_F_DRAIN_DISABLED. Simultaneously, an io-wq worker thread completing an asynchronous request in io_req_complete_post() without holding ctx->uring_lock reads ctx->int_flags & IO_RING_F_LOCKLESS_CQ using an unmarked plain C read. Because immutable setup flags (such as IO_RING_F_LOCKLESS_CQ) share the same 32-bit word with dynamic runtime flags (such as IO_RING_F_DRAIN_DISABLED), the concurrent unprotected write and read trigger a data race report in KCSAN.

▶ ▼ ✨ Full AI root cause analysis
Based on kernel commit 666539eecdf4:

Root Cause Analysis

1. Functions, Structs, and Fields Involved

  • Struct and Field: struct io_ring_ctx::int_flags (include/linux/io_uring_types.h:341), an unsigned int located at byte offset 4 of struct io_ring_ctx (in the hot, read-mostly cacheline directly after flags).
  • Flags Involved:
    • IO_RING_F_DRAIN_DISABLED (BIT(10)): Set at runtime when an SQE with IOSQE_CQE_SKIP_SUCCESS is processed.
    • IO_RING_F_LOCKLESS_CQ (BIT(7)): Set during ring initialization in io_uring_create() and remains invariant for the lifetime of struct io_ring_ctx.
  • Writers: io_submit_sqes() -> io_submit_sqe() -> io_init_req() (io_uring/io_uring.c:1939), executed by either the submitting user task or the SQPOLL kernel thread (io_sq_thread() / __io_sq_thread(), io_uring/sqpoll.c:252) holding ctx->uring_lock.
  • Readers: io_req_complete_post() (io_uring/io_uring.c:1019), called on asynchronous work completion by an io-wq worker thread (io_wq_worker -> io_worker_handle_work -> io_wq_submit_work -> io_issue_sqe -> io_req_complete_post) without holding ctx->uring_lock.

2. Technical Mechanism and Trigger Conditions

  1. Packing Immutable and Dynamic Flags in ctx->int_flags: In commit f1a424e21c15, individual bitfields in struct io_ring_ctx were converted into flags packed within a single 32-bit field (ctx->int_flags). This field stores both:

    • Static/invariant setup flags: Set once at ring creation in io_uring_create() (such as IO_RING_F_LOCKLESS_CQ, IO_RING_F_TASK_COMPLETE, IO_RING_F_SYSCALL_IOPOLL, and IO_RING_F_COMPAT).
    • Dynamic runtime flags: Updated during ring operations (such as IO_RING_F_DRAIN_DISABLED, IO_RING_F_DRAIN_ACTIVE, IO_RING_F_DRAIN_NEXT, IO_RING_F_POLL_ACTIVATED, etc.).
  2. Concurrent Write (CPU 0): When the SQPOLL thread (io_sq_thread) or user task submits SQEs via io_submit_sqes(), it holds ctx->uring_lock. If an SQE has IOSQE_CQE_SKIP_SUCCESS, io_init_req() executes:

    if (sqe_flags & IOSQE_CQE_SKIP_SUCCESS)
        ctx->int_flags |= IO_RING_F_DRAIN_DISABLED;
    

    This is an unmarked plain C read-modify-write operation on the 32-bit integer ctx->int_flags.

  3. Concurrent Read (CPU 1): Simultaneously, requests offloaded to io-wq run asynchronously without holding ctx->uring_lock. When an io-wq worker completes a request via io_req_complete_post(), it checks whether the ring uses a lockless CQ model to decide whether completions must be deferred via task_work or can take ctx->completion_lock:

    if ((ctx->int_flags & IO_RING_F_LOCKLESS_CQ) ||
        (req->flags & (REQ_F_REISSUE | REQ_F_IO_DRAIN))) {
    defer_complete:
        req->io_task_work.func = io_req_task_complete;
        io_req_task_work_add(req);
        return;
    }
    

    This is an unmarked plain C read of ctx->int_flags.

  4. KCSAN Detection: Because one thread performs a plain C write to ctx->int_flags while another thread concurrently performs a plain C read of ctx->int_flags without mutual exclusion or memory access annotations (such as READ_ONCE() / WRITE_ONCE() or data_race()), KCSAN flags the concurrent access as a data race.

▶ ▼ ✨ AI Jobs (3)
ID Workflow Result Correct Bug Created Started Finished Revision
f1779641 bisect-cause 🏃 KCSAN: data-race in io_issue_sqe / io_submit_sqes 2026/11/17 10:09 2026/11/17 10:09 a3e64cfc
6c96d0e5 assessment-kcsan Benign: ✅ ❓ KCSAN: data-race in io_issue_sqe / io_submit_sqes 2026/11/17 09:59 2026/11/17 09:59 2026/11/17 10:09 a3e64cfc
d0a93316 assessment-security DenialOfService: ❌ Exploitable: ❌ FilesystemTrigger: ❌ FuzzingArtifact: ❌ MemoryCorruption: ❌ NetworkNeedsSetup: ❌ NetworkTrigger: ❌ PeripheralTrigger: ❌ RemoteTrigger: ❌ Unprivileged: ✅ UserNamespace: ✅ VMGuestTrigger: ❌ VMHostTrigger: ❌ ❓ KCSAN: data-race in io_issue_sqe / io_submit_sqes 2026/11/17 09:52 2026/11/17 09:52 2026/11/17 10:11 a3e64cfc

Sample crash report:
==================================================================
BUG: KCSAN: data-race in io_issue_sqe / io_submit_sqes

write to 0xffff88811b2b6804 of 4 bytes by task 4324 on cpu 0:
 io_init_req io_uring/io_uring.c:1939 [inline]
 io_submit_sqe io_uring/io_uring.c:2044 [inline]
 io_submit_sqes+0xcf3/0x12b0 io_uring/io_uring.c:2212
 __io_sq_thread io_uring/sqpoll.c:252 [inline]
 io_sq_thread+0xaaa/0x16f0 io_uring/sqpoll.c:369
 ret_from_fork+0x146/0x330 arch/x86/kernel/process.c:158
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245

read to 0xffff88811b2b6804 of 4 bytes by task 4325 on cpu 1:
 io_req_complete_post io_uring/io_uring.c:1019 [inline]
 io_issue_sqe+0x535/0xd20 io_uring/io_uring.c:1546
 io_wq_submit_work+0x64d/0x8f0 io_uring/io_uring.c:1677
 io_worker_handle_work+0x688/0xd30 io_uring/io-wq.c:677
 io_wq_worker+0x2be/0xcb0 io_uring/io-wq.c:768
 ret_from_fork+0x146/0x330 arch/x86/kernel/process.c:158
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245

Reported by Kernel Concurrency Sanitizer on:
CPU: 1 UID: 0 PID: 4325 Comm: iou-wrk-4324 Not tainted syzkaller #0 PREEMPT(lazy) 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/06/2026
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2026/11/17 03:31 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in io_issue_sqe / io_submit_sqes
* Struck through repros no longer work on HEAD.