KCSAN: data-race in mm_update_next_owner / mm_update_next_owner

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

During process teardown (e.g. exit_group) with multiple threads, concurrent exiting threads invoke exit_mm() -> mm_update_next_owner(). The current owner thread updates mm->owner using WRITE_ONCE(mm->owner, tsk) in __try_to_set_owner(), while another exiting thread concurrently checks if it is the owner via the lockless, unmarked read 'if (mm->owner != p)' in mm_update_next_owner(). Because the read at kernel/exit.c:497 is not marked with READ_ONCE (or rcu_access_pointer), KCSAN flags a data race between the marked write and the unmarked read.

▶ ▼ ✨ Full AI root cause analysis
Based on kernel commit 4405c18c95d2:

Root Cause Analysis

1. Functions, Structs, and Fields Involved

  • Source File: kernel/exit.c
  • Functions: mm_update_next_owner() (lines 489–545) and helper __try_to_set_owner() (lines 454–468)
  • Struct and Field: struct mm_struct::owner (declared with __rcu in include/linux/mm_types.h:1377)

2. Detailed Technical Mechanism and Invariant Violation

When a task exits or performs exec, exit_mm() (or exec_mm_put_old()) calls mm_update_next_owner(mm) to find a new task to serve as the canonical owner of the mm_struct if the exiting task is the current owner.

In a multithreaded process where several threads exit concurrently (for example, as a result of do_group_exit() / sys_exit_group()):

  1. Thread 1 (Task 18863), which is the current mm->owner, enters exit_mm():

    • Clears current->mm = NULL under task_lock(current).
    • Calls mm_update_next_owner(mm).
    • Checks if (mm->owner != p). Because Thread 1 is indeed the owner, the check passes.
    • Finds an eligible surviving thread tsk (e.g., Thread 3) sharing the mm.
    • Inside __try_to_set_owner() (kernel/exit.c:462):
      WRITE_ONCE(mm->owner, tsk);
      
      mm->owner is updated using WRITE_ONCE().
  2. Thread 2 (Task 18867), another exiting thread sharing the same mm, concurrently enters exit_mm():

    • Clears its own current->mm = NULL under its task_lock.
    • Calls mm_update_next_owner(mm).
    • At the beginning of mm_update_next_owner() (kernel/exit.c:497), it executes:
      if (mm->owner != p)
          return;
      
    • This check is performed without holding any locks (tasklist_lock or any task locks).
    • Furthermore, the read mm->owner is a plain (unmarked) read.

Because Thread 1 writes to mm->owner using WRITE_ONCE() while Thread 2 concurrently reads mm->owner with a plain memory access, KCSAN detects a data race between a marked write (kernel/exit.c:462) and an unmarked read (kernel/exit.c:497).


3. Resolution

To conform to the kernel's memory model and eliminate the KCSAN data-race warning, the lockless read of mm->owner at line 497 in kernel/exit.c should be annotated using READ_ONCE(mm->owner) or rcu_access_pointer(mm->owner) (since mm->owner is an __rcu pointer).

▶ ▼ ✨ AI Jobs (2)
ID Workflow Result Correct Bug Created Started Finished Revision
59d0d72a assessment-security DenialOfService: ❌ Exploitable: ❌ FilesystemTrigger: ❌ FuzzingArtifact: ❌ MemoryCorruption: ❌ NetworkNeedsSetup: ❌ NetworkTrigger: ❌ PeripheralTrigger: ❌ RemoteTrigger: ❌ Unprivileged: ✅ UserNamespace: ✅ VMGuestTrigger: ❌ VMHostTrigger: ❌ ❓ KCSAN: data-race in mm_update_next_owner / mm_update_next_owner 2026/11/19 13:31 2026/11/19 13:31 2026/11/19 13:37 2006bdcc
c6b7d509 assessment-kcsan Benign: ✅ ❓ KCSAN: data-race in mm_update_next_owner / mm_update_next_owner 2026/11/19 13:24 2026/11/19 13:24 2026/11/19 13:45 2006bdcc

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

write (marked) to 0xffff8881043805f8 of 8 bytes by task 2218 on cpu 1:
 __try_to_set_owner kernel/exit.c:462 [inline]
 try_to_set_owner kernel/exit.c:477 [inline]
 mm_update_next_owner+0x504/0x570 kernel/exit.c:-1
 exit_mm+0x125/0x1d0 kernel/exit.c:585
 do_exit+0x44a/0x1530 kernel/exit.c:967
 do_group_exit+0xfe/0x140 kernel/exit.c:1123
 get_signal+0xc49/0xd30 kernel/signal.c:3113
 arch_do_signal_or_restart+0x96/0x480 arch/x86/kernel/signal.c:337
 __exit_to_user_mode_loop kernel/entry/common.c:66 [inline]
 exit_to_user_mode_loop+0x161/0x940 kernel/entry/common.c:101
 __exit_to_user_mode_prepare include/linux/irq-entry-common.h:207 [inline]
 syscall_exit_to_user_mode_prepare include/linux/irq-entry-common.h:230 [inline]
 syscall_exit_to_user_mode include/linux/entry-common.h:343 [inline]
 do_syscall_64+0x23b/0x3a0 arch/x86/entry/syscall_64.c:107
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

read to 0xffff8881043805f8 of 8 bytes by task 2225 on cpu 0:
 mm_update_next_owner+0x2e/0x570 kernel/exit.c:497
 exit_mm+0x125/0x1d0 kernel/exit.c:585
 do_exit+0x44a/0x1530 kernel/exit.c:967
 do_group_exit+0xfe/0x140 kernel/exit.c:1123
 get_signal+0xc49/0xd30 kernel/signal.c:3113
 arch_do_signal_or_restart+0x96/0x480 arch/x86/kernel/signal.c:337
 __exit_to_user_mode_loop kernel/entry/common.c:66 [inline]
 exit_to_user_mode_loop+0x161/0x940 kernel/entry/common.c:101
 __exit_to_user_mode_prepare include/linux/irq-entry-common.h:207 [inline]
 syscall_exit_to_user_mode_prepare include/linux/irq-entry-common.h:230 [inline]
 syscall_exit_to_user_mode include/linux/entry-common.h:343 [inline]
 do_syscall_64+0x23b/0x3a0 arch/x86/entry/syscall_64.c:107
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

value changed: 0xffff888100ba5640 -> 0xffff88812843b3c0

Reported by Kernel Concurrency Sanitizer on:
CPU: 0 UID: 0 PID: 2225 Comm: syz.2.5181 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/19 22:02 upstream 8dac6df92a2e 229865fb .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in mm_update_next_owner / mm_update_next_owner
2026/11/19 10:39 upstream 4405c18c95d2 f138241c .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in mm_update_next_owner / mm_update_next_owner
2026/11/18 21:32 upstream 4405c18c95d2 2006bdcc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in mm_update_next_owner / mm_update_next_owner
2026/11/18 09:29 upstream 20eef29b7c84 eb4895d7 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in mm_update_next_owner / mm_update_next_owner
2026/11/17 22:45 upstream 63fdb511c27a 122f94d5 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in mm_update_next_owner / mm_update_next_owner
2026/11/17 19:27 upstream 666539eecdf4 122f94d5 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in mm_update_next_owner / mm_update_next_owner
2026/11/17 11:56 upstream 666539eecdf4 43af6cac .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in mm_update_next_owner / mm_update_next_owner
2026/11/17 03:58 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in mm_update_next_owner / mm_update_next_owner
* Struck through repros no longer work on HEAD.