KCSAN: data-race in 0x0 / blk_account_io_start

Status: moderation: reported on 2026/11/20 00:00
Subsystems: block
Labels: prio:low race:benign
[Documentation on labels]
Reported-by: syzbot+251c5bf92bba96a3b8d1@syzkaller.appspotmail.com
First crash: 2d21h, last: 2d13h
✨ AI-generated root cause summary:

In blk_time_get_ns() (block/blk.h), the block layer attempts to cache timestamps for plugged I/O submissions by updating current->flags |= PF_BLOCK_TS using a plain, unannotated read-modify-write without disabling interrupts or preemption. When KCSAN places a watchpoint on current->flags at offset 0x2c of task_struct during blk_account_io_start(), task preemption under PREEMPT(lazy) allows the task to yield and later be scheduled back in on CPU 0. During context switch in finish_task_switch(), blk_plug_invalidate_ts() performs a plain 4-byte read of current->flags & PF_BLOCK_TS while the unwinder cannot resolve frames during task switch, triggering a data-race report against blk_time_get_ns(). Furthermore, non-atomic bitwise operations on current->flags violate concurrent access invariants when flags are inspected or cleared asynchronously across preemption points.

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

Root Cause Analysis

1. Functions, Structs, and Files Involved


2. Triggering Mechanism and Race Condition

  1. Unannotated Read-Modify-Write in blk_time_get_ns(): When a request is initiated through blk_account_io_start(), it retrieves the I/O start timestamp via blk_time_get_ns():

    now = READ_ONCE(plug->cur_ktime);
    if (!now) {
        now = ktime_get_ns();
        WRITE_ONCE(plug->cur_ktime, now);
        /* Ensure PF_BLOCK_TS is set after cur_ktime. */
        barrier();
        current->flags |= PF_BLOCK_TS;
    }
    

    current->flags |= PF_BLOCK_TS; is a plain C 4-byte read-modify-write operation on task_struct::flags. It does not use atomic bit operations, nor is it annotated with data_race() or synchronization wrappers.

  2. KCSAN Watchpoint & Preemption under PREEMPT(lazy): With CONFIG_KCSAN_STRICT=y enabled, kcsan_ignore_address() does not suppress races on &current->flags. Furthermore, with CONFIG_KCSAN_INTERRUPT_WATCHER=y, kcsan_setup_watchpoint() installs a watchpoint on &current->flags (0xffff8881045e67ac) and executes delay_access() without disabling preemption or local interrupts. During this delay on CPU 0, task 3288 is preempted under lazy preemption (PREEMPT(lazy)) and yields CPU 0.

  3. Conflicting Access in Context Switch Path (0x0 Stack): When task 3288 is subsequently scheduled back onto CPU 0, the scheduler's finish_task_switch() calls:

    /*
     * Any cached block-layer timestamp (plug->cur_ktime) is stale now,
     * invalidate it.
     */
    blk_plug_invalidate_ts();
    

    Inside blk_plug_invalidate_ts() (include/linux/blk_plug.h):

    static __always_inline void blk_plug_invalidate_ts(void)
    {
        if (unlikely(current->flags & PF_BLOCK_TS)) {
            current->plug->cur_ktime = 0;
            current->flags &= ~PF_BLOCK_TS;
        }
    }
    

    This performs a plain 4-byte read of current->flags. Because task 3288 is in task context (in_task() == true), prepare_access_info() assigns task_pid = task_pid_nr(current) (PID 3288 on CPU 0). Because the stack unwinder cannot resolve backtrace symbols during this transition in finish_task_switch(), stack_trace_save() returns zero valid frames (other_frame = 0x0), resulting in the KCSAN data-race report: BUG: KCSAN: data-race in 0x0 / blk_account_io_start.


3. Violated Invariants

  • current->flags contains multiple scheduler, memory-reclaim, and process-state flags (such as PF_MEMALLOC, PF_NOFREEZE, PF_VCPU, etc.) that can be examined or cleared across context switches, scheduler events, and asynchronous contexts. Performing unannotated, non-atomic bitwise read-modify-writes (current->flags |= PF_BLOCK_TS and current->flags &= ~PF_BLOCK_TS) without memory ordering or concurrency annotations violates KCSAN data race invariants and creates a window where plug->cur_ktime is set before PF_BLOCK_TS is observed.
▶ ▼ ✨ AI Jobs (2)
ID Workflow Result Correct Bug Created Started Finished Revision
498402af assessment-security DenialOfService: ❌ Exploitable: ❌ FilesystemTrigger: ❌ FuzzingArtifact: ❌ MemoryCorruption: ❌ NetworkNeedsSetup: ❌ NetworkTrigger: ❌ PeripheralTrigger: ❌ RemoteTrigger: ❌ Unprivileged: ✅ UserNamespace: ✅ VMGuestTrigger: ❌ VMHostTrigger: ❌ ❓ KCSAN: data-race in 0x0 / blk_account_io_start 2026/11/19 12:11 2026/11/19 12:11 2026/11/19 12:30 2006bdcc
df307583 assessment-kcsan Benign: ✅ ❓ KCSAN: data-race in 0x0 / blk_account_io_start 2026/11/19 12:10 2026/11/19 12:10 2026/11/19 12:52 2006bdcc

Sample crash report:
==================================================================
BUG: KCSAN: data-race in 0x0 / blk_account_io_start

read to 0xffff8881045e67ac of 4 bytes by task 3288 on cpu 0:

read-write to 0xffff8881045e67ac of 4 bytes by task 3288 on cpu 0:
 blk_time_get_ns block/blk.h:760 [inline]
 blk_account_io_start+0x3b3/0x480 block/blk-mq.c:1120
 blk_mq_bio_to_request block/blk-mq.c:2700 [inline]
 blk_mq_submit_bio+0xd8a/0x1310 block/blk-mq.c:3217
 __submit_bio+0x68/0x250 block/blk-core.c:674
 __submit_bio_noacct_mq block/blk-core.c:757 [inline]
 submit_bio_noacct_nocheck+0x168/0x650 block/blk-core.c:791
 submit_bio_noacct+0x810/0xa80 block/blk-core.c:929
 submit_bio+0x2a4/0x2c0 block/blk-core.c:970
 mpage_bio_submit_read fs/mpage.c:74 [inline]
 mpage_readahead+0x32f/0x380 fs/mpage.c:379
 blkdev_readahead+0x1c/0x30 block/fops.c:508
 read_pages+0xa8/0x5c0 mm/readahead.c:174
 page_cache_ra_unbounded+0x307/0x3f0 mm/readahead.c:315
 do_page_cache_ra mm/readahead.c:348 [inline]
 force_page_cache_ra+0x190/0x1d0 mm/readahead.c:378
 page_cache_sync_ra+0x133/0x580 mm/readahead.c:602
 filemap_get_pages+0x314/0x1020 mm/filemap.c:2743
 filemap_read+0x20d/0x8d0 mm/filemap.c:2853
 blkdev_read_iter+0x29c/0x390 block/fops.c:892
 new_sync_read fs/read_write.c:473 [inline]
 vfs_read+0x6ac/0x7d0 fs/read_write.c:554
 ksys_read+0xdc/0x1a0 fs/read_write.c:696
 __do_sys_read fs/read_write.c:705 [inline]
 __se_sys_read fs/read_write.c:703 [inline]
 __x64_sys_read+0x40/0x50 fs/read_write.c:703
 x64_sys_call+0x2135/0x2550 arch/x86/include/generated/asm/syscalls_64.h:1
 do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
 do_syscall_64+0x11e/0x3a0 arch/x86/entry/syscall_64.c:89
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

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

Crashes (18):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2026/11/17 11:26 upstream 666539eecdf4 43af6cac .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / blk_account_io_start
2026/11/17 10:13 upstream 666539eecdf4 43af6cac .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / blk_account_io_start
2026/11/17 06:36 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / blk_account_io_start
2026/11/17 06:30 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / blk_account_io_start
2026/11/17 06:29 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / blk_account_io_start
2026/11/17 06:08 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / blk_account_io_start
2026/11/17 06:07 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / blk_account_io_start
2026/11/17 06:07 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / blk_account_io_start
2026/11/17 05:58 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / blk_account_io_start
2026/11/17 05:52 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / blk_account_io_start
2026/11/17 05:50 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / blk_account_io_start
2026/11/17 05:33 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / blk_account_io_start
2026/11/17 05:00 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / blk_account_io_start
2026/11/17 04:52 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / blk_account_io_start
2026/11/17 04:20 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / blk_account_io_start
2026/11/17 04:00 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / blk_account_io_start
2026/11/17 03:55 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / blk_account_io_start
2026/11/17 03:42 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / blk_account_io_start
* Struck through repros no longer work on HEAD.