KCSAN: data-race in 0x0 / start_this_handle

Status: moderation: reported on 2026/11/18 06:36
Subsystems: ext4
Labels: race:benign prio:low
[Documentation on labels]
Reported-by: syzbot+28899ff8ebb611af948e@syzkaller.appspotmail.com
First crash: 1d03h, last: 10h02m
✨ AI-generated root cause summary:

A KCSAN data-race report was triggered on task_struct::flags when start_this_handle() called memalloc_nofs_save() -> memalloc_flags_save(), performing an unmarked read-modify-write (current->flags |= PF_MEMALLOC_NOFS). When KCSAN arming a watchpoint in kcsan_setup_watchpoint() does not disable local IRQs or preemption (as kcsan_interrupt_watcher was enabled and ctx->disable_count was not incremented), task 4140 spun in delay_access() -> udelay() with interrupts and preemption active. While spinning, an asynchronous path on CPU 0 with in_task() == true performed an instrumented read of current->flags and consumed task 4140's own watchpoint. Because the racing read occurred at a frame boundary where stack unwinding yielded no frames after KCSAN skip filtering, the conflicting IP was displayed as 0x0 with an empty stack trace.

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

Root Cause Analysis

1. Target Address and Memory Access

The reported address 0xffff88810397a2ac corresponds to current->flags (struct task_struct::flags, an aligned 32-bit unsigned int located at offset 0x2c / bit offset 352 in include/linux/sched.h) of task 4140 (syz.3.290) running on CPU 0.

During ext4 shared page fault processing:

ext4_page_mkwrite()
  file_update_time()
    ext4_dirty_inode()
      __ext4_journal_start()
        start_this_handle() (fs/jbd2/transaction.c:450)
          memalloc_nofs_save() (include/linux/sched/mm.h:388)
            memalloc_flags_save() (include/linux/sched/mm.h:335)

memalloc_flags_save() executes:

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

Because current->flags |= flags; is an unmarked plain read-modify-write (RMW), compiler TSAN instrumentation emits __tsan_read_write4(&current->flags).

2. KCSAN Watchpoint Setup and Self-Interception Mechanism

When check_access() in kernel/kcsan/core.c handles the __tsan_read_write4 call:

  1. It chooses to arm a watchpoint on &current->flags via kcsan_setup_watchpoint().
  2. In kcsan_setup_watchpoint():
    • Only ctx->disable_scoped++ is incremented (line 581); ctx->disable_count is not incremented, leaving KCSAN active for task 4140.
    • When kcsan_interrupt_watcher is true (the default when enabled), local interrupts are not disabled (local_irq_save() is skipped).
    • KCSAN calls delay_access(type) -> udelay(delay) to spin and observe concurrent conflicting accesses.
  3. On x86 (arch/x86/lib/delay.c:61-78), delay_tsc() executes a loop that periodically calls:
    preempt_enable();
    native_pause();
    preempt_disable();
    
    Under PREEMPT(lazy) or preemptible kernels with interrupts enabled, asynchronous events (such as hardware timer interrupts or preemption checks on interrupt return) can execute on CPU 0 while spinning inside udelay().
  4. On exit from an interrupt handler or during preempt_enable(), when HARDIRQ_MASK and SOFTIRQ_OFFSET are clear, in_task() (include/linux/preempt.h:160) evaluates to true.
  5. If an asynchronous task-context code path (e.g., in scheduler preemption via preempt_schedule_irq(), BPF hooks, or tracing) reads current->flags, compiler instrumentation invokes __tsan_read4(&current->flags).
  6. Because kcsan_is_enabled(ctx) remains true and a watchpoint is active on &current->flags, this read enters kcsan_found_watchpoint():
    • try_consume_watchpoint() succeeds and consumes the watchpoint.
    • kcsan_report_set_info() records the access in other_infos[watchpoint_idx], populating other_info->ai.task_pid = task_pid_nr(current) (4140) and other_info->ai.cpu_id (0).
  7. When the interrupted context resumes in kcsan_setup_watchpoint(), consume_watchpoint() returns false because the watchpoint was already consumed. This triggers kcsan_report_known_origin(), which prints a race between the producer (other_info) and the consumer (ai), reporting a data-race between task 4140 and task 4140 on CPU 0.

3. Reason for 0x0 and Missing Stack Trace Frames

In print_report() (kernel/kcsan/report.c:412-457):

  • other_info->num_stack_entries was saved via stack_trace_save(other_info->stack_entries, NUM_STACK_ENTRIES, 2).
  • If the asynchronous read occurred at an entry/ASM/JIT boundary where the frame unwinder records no frames, or if all unwound frames matched KCSAN skip patterns (get_stack_skipnr()), other_skipnr equals other_info->num_stack_entries, leaving other_frame == 0.
  • In print_report(), cmp = sym_strcmp((void *)other_frame, (void *)this_frame); orders 0x0 before start_this_handle (0x0 < start_this_handle), formatting the report title as BUG: KCSAN: data-race in 0x0 / start_this_handle.
  • print_stack_trace() is passed num_stack_entries - other_skipnr == 0, printing zero lines under read to 0xffff88810397a2ac of 4 bytes by task 4140 on cpu 0:.

4. Invariants and Correctness

  • task_struct::flags is updated strictly sequentially by the owning task (current) in task context; concurrent threads only read immutable or atomic flags locklessly.
  • The PF_MEMALLOC_NOFS flag is only checked by current (e.g., via current_gfp_context()) to avoid filesystem recursion during allocations.
  • This report is an artifact of KCSAN watchpoint re-entrancy / unmarked memory accesses when interrupt/preemption watching is enabled, rather than true concurrent data corruption.
▶ ▼ ✨ AI Jobs (2)
ID Workflow Result Correct Bug Created Started Finished Revision
f10f517e assessment-kcsan Benign: ✅ ❓ KCSAN: data-race in 0x0 / start_this_handle 2026/11/18 06:12 2026/11/18 06:12 2026/11/18 06:26 eb4895d7
a03627aa assessment-security DenialOfService: ❌ Exploitable: ❌ FilesystemTrigger: ❌ FuzzingArtifact: ❌ MemoryCorruption: ❌ NetworkNeedsSetup: ❌ NetworkTrigger: ❌ PeripheralTrigger: ❌ RemoteTrigger: ❌ Unprivileged: ✅ UserNamespace: ✅ VMGuestTrigger: ❌ VMHostTrigger: ❌ ❓ KCSAN: data-race in 0x0 / start_this_handle 2026/11/18 06:10 2026/11/18 06:10 2026/11/18 06:29 eb4895d7

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

read to 0xffff88810397a2ac of 4 bytes by task 4140 on cpu 0:

read-write to 0xffff88810397a2ac of 4 bytes by task 4140 on cpu 0:
 memalloc_flags_save include/linux/sched/mm.h:335 [inline]
 memalloc_nofs_save include/linux/sched/mm.h:388 [inline]
 start_this_handle+0x12c0/0x1330 fs/jbd2/transaction.c:450
 jbd2__journal_start+0x1db/0x3c0 fs/jbd2/transaction.c:502
 __ext4_journal_start_sb+0xd6/0x3d0 fs/ext4/ext4_jbd2.c:126
 __ext4_journal_start fs/ext4/ext4_jbd2.h:238 [inline]
 ext4_dirty_inode+0x60/0xc0 fs/ext4/inode.c:7650
 __mark_inode_dirty+0x164/0x770 fs/fs-writeback.c:2751
 generic_update_time fs/inode.c:2274 [inline]
 file_update_time_flags+0x2ae/0x2e0 fs/inode.c:2504
 file_update_time+0x17/0x20 fs/inode.c:2525
 ext4_page_mkwrite+0x16b/0xd30 fs/ext4/inode.c:7838
 do_page_mkwrite mm/memory.c:3889 [inline]
 do_shared_fault mm/memory.c:6188 [inline]
 do_fault mm/memory.c:6250 [inline]
 do_pte_missing mm/memory.c:4778 [inline]
 handle_pte_fault mm/memory.c:6665 [inline]
 __handle_mm_fault mm/memory.c:6817 [inline]
 handle_mm_fault+0x269c/0x3880 mm/memory.c:6984
 do_user_addr_fault+0x3ce/0xde0 arch/x86/mm/fault.c:1343
 handle_page_fault arch/x86/mm/fault.c:1483 [inline]
 exc_page_fault+0x62/0xa0 arch/x86/mm/fault.c:1536
 asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:595

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

Crashes (113):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2026/11/17 20:29 upstream 666539eecdf4 122f94d5 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / start_this_handle
2026/11/17 19:21 upstream 666539eecdf4 122f94d5 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / start_this_handle
2026/11/17 18:55 upstream 666539eecdf4 122f94d5 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / start_this_handle
2026/11/17 17:00 upstream 666539eecdf4 122f94d5 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / start_this_handle
2026/11/17 15:22 upstream 666539eecdf4 43af6cac .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / start_this_handle
2026/11/17 15:19 upstream 666539eecdf4 43af6cac .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / start_this_handle
2026/11/17 14:07 upstream 666539eecdf4 43af6cac .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / start_this_handle
2026/11/17 12:55 upstream 666539eecdf4 43af6cac .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / start_this_handle
2026/11/17 12:03 upstream 666539eecdf4 43af6cac .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / start_this_handle
2026/11/17 08:34 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / start_this_handle
2026/11/17 07:30 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / start_this_handle
2026/11/17 07:23 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / start_this_handle
2026/11/17 07:21 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / start_this_handle
2026/11/17 06:50 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / start_this_handle
2026/11/17 06:43 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / start_this_handle
2026/11/17 06:43 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / start_this_handle
2026/11/17 06:42 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / start_this_handle
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 / start_this_handle
2026/11/17 06:33 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / start_this_handle
2026/11/17 06:28 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / start_this_handle
2026/11/17 06:27 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / start_this_handle
2026/11/17 06:27 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / start_this_handle
2026/11/17 06:25 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / start_this_handle
2026/11/17 06:24 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / start_this_handle
2026/11/17 06:23 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / start_this_handle
2026/11/17 06:14 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / start_this_handle
2026/11/17 06:10 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / start_this_handle
2026/11/17 06:06 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / start_this_handle
2026/11/17 06:05 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / start_this_handle
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 / start_this_handle
2026/11/17 05:51 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / start_this_handle
2026/11/17 05:51 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / start_this_handle
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 / start_this_handle
2026/11/17 05:30 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / start_this_handle
2026/11/17 05:22 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / start_this_handle
2026/11/17 04:57 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / start_this_handle
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 / start_this_handle
2026/11/17 04:43 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / start_this_handle
2026/11/17 04:42 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / start_this_handle
2026/11/17 04:40 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / start_this_handle
2026/11/17 04:33 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / start_this_handle
2026/11/17 04:27 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / start_this_handle
2026/11/17 04:11 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / start_this_handle
* Struck through repros no longer work on HEAD.