KCSAN: data-race in do_exit / get_signal (3)

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

A KCSAN data race occurs on task_struct::flags between a thread setting PF_SIGNALED in get_signal() (current->flags |= PF_SIGNALED after dropping sighand->siglock) and an exiting sibling thread checking !(t->flags & PF_EXITING) in find_alive_thread() while holding tasklist_lock. Neither side uses READ_ONCE()/WRITE_ONCE() or shares a common lock for t->flags updates outside exit_signals(), allowing concurrent unmarked 4-byte accesses to the same unsigned int flags field. The race is benign in practice because current is the sole writer to t->flags and tasklist_lock serializes exit_notify().

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

Root Cause Analysis

The KCSAN report identifies a data race on the 4-byte flags field (unsigned int flags at offset 44 in struct task_struct, include/linux/sched.h:858) of task 7741 between two concurrent paths in the same thread group:

  1. Read-write side (kernel/signal.c:3084, task 7741): In get_signal(), after handling a fatal signal and releasing sighand->siglock at line 3077, task 7741 performs an unmarked read-modify-write on its own task_struct::flags:

    current->flags |= PF_SIGNALED; // PF_SIGNALED = 0x00000400
    

    Task 7741 then enters do_group_exit() -> do_exit(), setting PF_POSTCOREDUMP (0x00000008 in synchronize_group_exit() at kernel/exit.c:892) and PF_EXITING (0x00000004 in exit_signals() at kernel/signal.c:3211), which explains the observed transition 0x00400140 -> 0x0040054c (0x0000040c) during the KCSAN watchpoint window.

  2. Read side (kernel/exit.c:596, task 7739): Task 7739, an exiting sibling thread in do_exit() -> exit_notify() (kernel/exit.c:748), acquires write_lock_irq(&tasklist_lock) and calls forget_original_parent() -> find_new_reaper() -> find_alive_thread(father):

    static struct task_struct *find_alive_thread(struct task_struct *p)
    {
        struct task_struct *t;
    
        for_each_thread(p, t) {
            if (!(t->flags & PF_EXITING))
                return t;
        }
        return NULL;
    }
    

    find_alive_thread() reads t->flags directly without READ_ONCE() and without holding t->sighand->siglock.

Trigger & Invariant Details

  • task_struct::flags is generally updated only by current without locking, except exit_signals() (kernel/signal.c:3210-3211) sets PF_EXITING under tsk->sighand->siglock so signal-delivery paths holding siglock see a consistent PF_EXITING state.
  • find_alive_thread() holds tasklist_lock rather than sighand->siglock while scanning sibling threads (or subreaper threads), and performs an unmarked read of t->flags.
  • Meanwhile, get_signal() sets PF_SIGNALED on current->flags after dropping sighand->siglock (and without WRITE_ONCE() or tasklist_lock), causing an unmarked concurrent read and read-modify-write on t->flags.
  • Functionally, tasklist_lock still preserves reparenting invariants: exit_signals() sets PF_EXITING before do_exit() reaches exit_notify(), which acquires write_lock_irq(&tasklist_lock). Any sibling t returned by find_alive_thread() while tasklist_lock is held cannot yet have executed exit_notify(), so t will acquire tasklist_lock afterwards and reparent any children assigned to it. To satisfy KCSAN and avoid compiler load/store tearing on cross-thread t->flags inspection, find_alive_thread() should use READ_ONCE(t->flags) (paired with WRITE_ONCE() / atomic or marked updates on current->flags when modifying flags concurrently with external readers).
▶ ▼ ✨ AI Jobs (2)
ID Workflow Result Correct Bug Created Started Finished Revision
dcf8f0e7 assessment-security DenialOfService: ❌ Exploitable: ❌ FilesystemTrigger: ❌ FuzzingArtifact: ❌ MemoryCorruption: ❌ NetworkNeedsSetup: ❌ NetworkTrigger: ❌ PeripheralTrigger: ❌ RemoteTrigger: ❌ Unprivileged: ✅ UserNamespace: ✅ VMGuestTrigger: ❌ VMHostTrigger: ❌ ❓ KCSAN: data-race in do_exit / get_signal (3) 2026/11/19 18:37 2026/11/19 18:37 2026/11/19 18:40 229865fb
594eb2a7 assessment-kcsan Benign: ✅ ❓ KCSAN: data-race in do_exit / get_signal (3) 2026/11/19 18:36 2026/11/19 18:36 2026/11/19 18:39 229865fb
▶ ▼ Similar bugs (2)
Kernel Title Rank 🛈 Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KCSAN: data-race in do_exit / get_signal kernel 6 9 2215d 2321d 0/29 auto-closed as invalid on 2020/11/30 13:39
upstream KCSAN: data-race in do_exit / get_signal (2) kernel 6 27 1986d 2170d 0/29 auto-closed as invalid on 2021/07/17 21:02

Sample crash report:
loop5: detected capacity change from 0 to 33792
EXT4-fs: Ignoring removed bh option
EXT4-fs (loop5): can't mount with data_err=abort, fs mounted w/o journal
==================================================================
BUG: KCSAN: data-race in do_exit / get_signal

read-write to 0xffff888101df22ac of 4 bytes by task 7741 on cpu 0:
 get_signal+0xac5/0xd30 kernel/signal.c:3084
 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 0xffff888101df22ac of 4 bytes by task 7739 on cpu 1:
 find_alive_thread kernel/exit.c:596 [inline]
 find_new_reaper kernel/exit.c:646 [inline]
 forget_original_parent kernel/exit.c:716 [inline]
 exit_notify kernel/exit.c:749 [inline]
 do_exit+0x5b6/0x1530 kernel/exit.c:992
 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: 0x00400140 -> 0x0040054c

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

Crashes (3):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2026/11/19 13:38 upstream 4405c18c95d2 f138241c .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in do_exit / get_signal
2026/11/17 15:01 upstream 666539eecdf4 43af6cac .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in do_exit / get_signal
2026/11/17 06:13 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in do_exit / get_signal
* Struck through repros no longer work on HEAD.