KCSAN: data-race in 0x0 / dquot_commit

Status: moderation: reported on 2026/11/19 00:07
Subsystems: fs
Labels: prio:low race:benign
[Documentation on labels]
Reported-by: syzbot+0ddae57d211754dfd4fe@syzkaller.appspotmail.com
First crash: 1d18h, last: 1d06h
✨ AI-generated root cause summary:

A data race was reported by KCSAN on current->flags (struct task_struct::flags) during memalloc_flags_restore() in include/linux/sched/mm.h. When exiting a memory allocation scope such as memalloc_nofs_save()/memalloc_nofs_restore() (invoked here by dquot_commit()), memalloc_flags_restore() performs a plain, unmarked read-modify-write operation (current->flags &= ~flags;). With CONFIG_KCSAN_INTERRUPT_WATCHER enabled, interrupts remain enabled during the watchpoint delay, allowing an interrupt or preemption path on the same CPU to perform an unmarked read of current->flags. Because accesses to current->flags are not instrumented with READ_ONCE()/WRITE_ONCE() or atomic operations, KCSAN flags this concurrent access as a data race.

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

Root Cause Analysis

1. Confirmed Racing Object and Location

The racing 4-byte memory address 0xffff88810176d66c corresponds to current->flags (struct task_struct::flags, 32 bits, offset 0x2c / 352 bits) of the running task (PID 4922, base task_struct address 0xffff88810176d640).

The reported read-write access occurred at:

2. Mechanism and How the Race is Triggered

  1. Unmarked Access in memalloc_flags_restore: In include/linux/sched/mm.h, memory allocation scope helpers save and restore per-task allocation control flags (PF_MEMALLOC, PF_MEMALLOC_NOFS, PF_MEMALLOC_NOIO, etc.):

    static inline unsigned memalloc_flags_save(unsigned flags)
    {
        unsigned oldflags = ~current->flags & flags;
        current->flags |= flags;
        return oldflags;
    }
    
    static inline void memalloc_flags_restore(unsigned flags)
    {
        current->flags &= ~flags;
    }
    

    Both operations perform plain, unmarked C read-modify-write accesses directly on current->flags without atomic bitops or READ_ONCE() / WRITE_ONCE().

  2. KCSAN Watchpoint Handling with CONFIG_KCSAN_INTERRUPT_WATCHER: When dquot_commit() executes memalloc_nofs_restore() and enters memalloc_flags_restore(), KCSAN sets up a watchpoint on current->flags. Under CONFIG_KCSAN_INTERRUPT_WATCHER=y (kcsan_interrupt_watcher = true in kernel/kcsan/core.c), kcsan_setup_watchpoint() deliberately leaves local IRQs and preemption enabled on the CPU during delay_access().

  3. Same-CPU Concurrent Read During Interrupt / Preemption: While the watchpoint is active during the simulated delay on CPU 1, an interrupt fires or an IRQ return/preemption event occurs. In this context on CPU 1:

    • Routine kernel code (such as scheduler accounting, preemption checks, tick processing, or task state inspection) performs an unmarked 4-byte read of current->flags (e.g., checking PF_WQ_WORKER, PF_VCPU, or PF_EXITING).
    • in_task() remains true or prepare_access_info() attributes the access to task_pid_nr(current) on CPU 1, recording ai.task_pid = 4922 and ai.cpu_id = 1.
    • The stack trace inside the interrupt/KCSAN framework is filtered out by sanitize_stack_entries(), resulting in 0 remaining frames, which causes KCSAN to format the other access as 0x0 in the title and omit stack frames in the report output.
  4. Resulting Violation: According to the Linux Kernel Memory Model (LKMM), concurrent unmarked reads and writes to the same variable constitute a data race. task_struct::flags is accessed concurrently by asynchronous contexts (interrupt/tick/preemption handlers or cross-thread readers) while memalloc_flags_save() and memalloc_flags_restore() update it with plain bitwise operations.

▶ ▼ ✨ AI Jobs (2)
ID Workflow Result Correct Bug Created Started Finished Revision
eab416d5 assessment-kcsan Benign: ✅ ❓ KCSAN: data-race in 0x0 / dquot_commit 2026/11/18 13:58 2026/11/18 13:58 2026/11/18 14:04 e99b1095
a4b3a4d8 assessment-security DenialOfService: ❌ Exploitable: ❌ FilesystemTrigger: ❌ FuzzingArtifact: ❌ MemoryCorruption: ❌ NetworkNeedsSetup: ❌ NetworkTrigger: ❌ PeripheralTrigger: ❌ RemoteTrigger: ❌ Unprivileged: ✅ UserNamespace: ✅ VMGuestTrigger: ❌ VMHostTrigger: ❌ ❓ KCSAN: data-race in 0x0 / dquot_commit 2026/11/18 12:43 2026/11/18 12:43 2026/11/18 12:55 eb4895d7

Sample crash report:
loop4: detected capacity change from 0 to 33280
ext4 filesystem being mounted at /92/file1 supports timestamps until 2038-01-19 (0x7fffffff)
==================================================================
BUG: KCSAN: data-race in 0x0 / dquot_commit

read to 0xffff88810176d66c of 4 bytes by task 4922 on cpu 1:

read-write to 0xffff88810176d66c of 4 bytes by task 4922 on cpu 1:
 memalloc_flags_restore include/linux/sched/mm.h:341 [inline]
 memalloc_nofs_restore include/linux/sched/mm.h:401 [inline]
 dquot_commit+0x25d/0x280 fs/quota/dquot.c:544
 ext4_write_dquot+0x126/0x1d0 fs/ext4/super.c:7096
 ext4_mark_dquot_dirty+0x95/0xd0 fs/ext4/super.c:7173
 mark_dquot_dirty fs/quota/dquot.c:398 [inline]
 mark_all_dquot_dirty fs/quota/dquot.c:438 [inline]
 __dquot_alloc_space+0x7f4/0x8c0 fs/quota/dquot.c:1713
 dquot_alloc_space_nodirty include/linux/quotaops.h:297 [inline]
 dquot_alloc_space include/linux/quotaops.h:310 [inline]
 dquot_alloc_block include/linux/quotaops.h:334 [inline]
 ext4_mb_new_blocks+0x903/0x20a0 fs/ext4/mballoc.c:6275
 ext4_ext_map_blocks+0xe25/0x2d80 fs/ext4/extents.c:4469
 ext4_map_create_blocks+0xe5/0x3c0 fs/ext4/inode.c:692
 ext4_map_blocks+0x8bb/0xfc0 fs/ext4/inode.c:937
 ext4_alloc_file_blocks+0x342/0xcd0 fs/ext4/extents.c:4665
 ext4_zero_range+0x211/0x970 fs/ext4/extents.c:4812
 ext4_fallocate+0x2d4/0x320 fs/ext4/extents.c:5039
 vfs_fallocate+0x3ac/0x400 fs/open.c:338
 ksys_fallocate fs/open.c:362 [inline]
 __do_sys_fallocate fs/open.c:367 [inline]
 __se_sys_fallocate fs/open.c:365 [inline]
 __x64_sys_fallocate+0x7a/0xd0 fs/open.c:365
 x64_sys_call+0x1e1d/0x2550 arch/x86/include/generated/asm/syscalls_64.h:286
 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: 1 UID: 0 PID: 4922 Comm: syz.4.445 Not tainted syzkaller #0 PREEMPT(lazy) 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/06/2026
==================================================================

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2026/11/17 18:32 upstream 666539eecdf4 122f94d5 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / dquot_commit
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 / dquot_commit
* Struck through repros no longer work on HEAD.