KCSAN: data-race in 0x0 / fpu_flush_thread

Status: upstream: reported on 2026/11/19 03:42
Subsystems: kernel
Labels: prio:high race:harmful
[Documentation on labels]
Reported-by: syzbot+58cbd7974a103b8b8916@syzkaller.appspotmail.com
First crash: 2d01h, last: 1d08h
✨ AI-generated root cause summary:

In fpu_flush_thread() (invoked during execve via flush_thread()), fpstate_reset() modifies the task's fpu->fpstate pointer and resets fpstate configuration fields without holding fpregs_lock() and before the live hardware FPU registers are invalidated. If preemption or a softirq occurs during fpstate_reset(), switch_fpu() executes save_fpregs_to_fpstate(), which concurrently reads fpstate->xfeatures and writes hardware register state into fpu->fpstate. When dynamic features such as AMX are active, saving live registers into the newly assigned default fixed fpstate buffer triggers an out-of-bounds memory write.

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

Root Cause Analysis: KCSAN Data Race in fpu_flush_thread

1. Functions, Structs, and Files Involved

2. Root Cause & Invariant Violation

The core FPU locking invariant (documented in arch/x86/include/asm/fpu/api.h:52-56) dictates:

"Use fpregs_lock() while editing CPU's FPU registers or fpu->fpstate, or while using the FPU in kernel mode. A context switch will (and softirq might) save CPU's FPU registers to fpu->fpstate.regs and set TIF_NEED_FPU_LOAD leaving CPU's FPU registers in a random state."

During an execve syscall, flush_thread() calls fpu_flush_thread():

void fpu_flush_thread(void)
{
	fpstate_reset(x86_task_fpu(current));
	fpu_reset_fpstate_regs();
}

In fpstate_reset(struct fpu *fpu):

	fpu->fpstate = &fpu->__fpstate;
	__fpstate_reset(fpu->fpstate);

fpstate_reset() updates fpu->fpstate to point to the embedded default &fpu->__fpstate and writes several 8-byte configuration fields (xfeatures, xfd, user_xfeatures) via __fpstate_reset(). However:

  1. fpstate_reset() is called without acquiring fpregs_lock().
  2. The calling task is running in normal preemptible process context with softirqs enabled (PREEMPT(lazy)).
  3. The task's pre-execve user FPU register states are still active in hardware registers, and TIF_NEED_FPU_LOAD is not yet set (it is only set subsequently within fpu_reset_fpstate_regs()).

3. How the Race Occurs and Produces the KCSAN Splat

When __fpstate_reset() performs an 8-byte write to fpstate->xfeatures (0xffff888104809f18), KCSAN sets a watchpoint and executes delay_access() with interrupts and preemption enabled.

A preemption / reschedule occurs on CPU 0:

  1. The scheduler invokes __switch_to_asm, which switches %rsp to the incoming task (next_p)'s stack and calls __switch_to(prev_p, next_p).
  2. Inside __switch_to(), before raw_cpu_write(current_task, next_p) updates current to next_p, it calls switch_fpu(prev_p, cpu).
  3. Because TIF_NEED_FPU_LOAD has not yet been set for prev_p, switch_fpu() calls update_fpu_state_and_flag() -> save_fpregs_to_fpstate() -> os_xsave(fpu->fpstate).
  4. os_xsave() executes u64 mask = fpstate->xfeatures;, triggering an 8-byte concurrent read on the exact location being modified by __fpstate_reset().
  5. Because current is still prev_p (task 10978 on CPU 0) at this point in __switch_to(), but the CPU stack pointer %rsp is already pointing to next_p's stack, KCSAN's stack_trace_save() cannot unwind the stack for current and returns 0 frames (0x0), resulting in the header: BUG: KCSAN: data-race in 0x0 / fpu_flush_thread.

4. Real-World Failure Consequence

Beyond the data race, if the task was previously using dynamic extended features (such as Intel AMX), its fpu->fpstate pointed to a large vzalloc'd buffer. Because fpstate_reset() resets fpu->fpstate = &fpu->__fpstate before invalidating hardware register state or setting TIF_NEED_FPU_LOAD, a preemption or softirq in this window causes switch_fpu() to execute XSAVE for the large live register state into the smaller default &fpu->__fpstate buffer, causing an out-of-bounds write and kernel memory corruption.

▶ ▼ ✨ AI Jobs (3)
ID Workflow Result Correct Bug Created Started Finished Revision
cdd9bad8 repro-c 🏃 KCSAN: data-race in 0x0 / fpu_flush_thread 2026/11/19 03:37 2026/11/19 03:37 2006bdcc
5ce23c3d assessment-kcsan Benign: ❌ ❓ KCSAN: data-race in 0x0 / fpu_flush_thread 2026/11/19 03:25 2026/11/19 03:25 2026/11/19 03:37 2006bdcc
1b321d6a assessment-security DenialOfService: ✅ Exploitable: ✅ FilesystemTrigger: ❌ FuzzingArtifact: ❌ MemoryCorruption: ✅ NetworkNeedsSetup: ❌ NetworkTrigger: ❌ PeripheralTrigger: ❌ RemoteTrigger: ❌ Unprivileged: ✅ UserNamespace: ✅ VMGuestTrigger: ❌ VMHostTrigger: ❌ ❓ KCSAN: data-race in 0x0 / fpu_flush_thread 2026/11/19 03:24 2026/11/19 03:24 2026/11/19 03:33 2006bdcc
▶ ▼ Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [kernel?] KCSAN: data-race in 0x0 / fpu_flush_thread 0 (1) 2026/11/19 03:42

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

read to 0xffff888104809f18 of 8 bytes by task 10978 on cpu 0:

write to 0xffff888104809f18 of 8 bytes by task 10978 on cpu 0:
 __fpstate_reset arch/x86/kernel/fpu/core.c:-1 [inline]
 fpstate_reset arch/x86/kernel/fpu/core.c:620 [inline]
 fpu_flush_thread+0x128/0x360 arch/x86/kernel/fpu/core.c:882
 flush_thread+0x40/0x80 arch/x86/kernel/process.c:291
 begin_new_exec+0xcd0/0x1260 fs/exec.c:1235
 load_elf_binary+0x5ee/0x1a00 fs/binfmt_elf.c:1010
 search_binary_handler fs/exec.c:1777 [inline]
 exec_binprm fs/exec.c:1809 [inline]
 bprm_execve+0x480/0xaa0 fs/exec.c:1865
 do_execveat_common+0x6ba/0x720 fs/exec.c:1963
 __do_sys_execve fs/exec.c:2036 [inline]
 __se_sys_execve fs/exec.c:2030 [inline]
 __x64_sys_execve+0x5f/0x80 fs/exec.c:2030
 x64_sys_call+0x1cd2/0x2550 arch/x86/include/generated/asm/syscalls_64.h:60
 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: 10978 Comm: dhcpcd-run-hook Not tainted syzkaller #0 PREEMPT(lazy) 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/06/2026
==================================================================

Crashes (8):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2026/11/17 20:52 upstream 666539eecdf4 122f94d5 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / fpu_flush_thread
2026/11/17 15:11 upstream 666539eecdf4 43af6cac .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / fpu_flush_thread
2026/11/17 13:31 upstream 666539eecdf4 43af6cac .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / fpu_flush_thread
2026/11/17 12:57 upstream 666539eecdf4 43af6cac .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / fpu_flush_thread
2026/11/17 12:21 upstream 666539eecdf4 43af6cac .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / fpu_flush_thread
2026/11/17 11:32 upstream 666539eecdf4 43af6cac .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / fpu_flush_thread
2026/11/17 04:48 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / fpu_flush_thread
2026/11/17 03:22 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / fpu_flush_thread
* Struck through repros no longer work on HEAD.