KCSAN: data-race in detach_pid / pid_delete_dentry

Status: moderation: reported on 2026/11/18 00:04
Subsystems: kernel
Labels: prio:low race:benign
[Documentation on labels]
Reported-by: syzbot+d608d486bd3b7062bafc@syzkaller.appspotmail.com
First crash: 4h45m, last: 4h45m
✨ AI cause bisection: candidate commits (most relevant first) (AI job):
  13b41b09491e [PATCH] proc: Use struct pid not struct task_ref
  d855a4b79f49 proc: don't (ab)use ->group_leader in proc_task_readdir() paths
  7bc3e6e55acf proc: Use a list of inodes to flush from proc
  
✨ AI-generated root cause summary:

In fs/proc/base.c, proc_inode_is_dead() open-codes the check for whether a PID has active tasks by performing a plain, unmarked read of proc_pid(inode)->tasks[PIDTYPE_PID].first without holding tasklist_lock. Concurrently, when a task is reaped (e.g., via release_task() -> __exit_signal() -> detach_pid()), __hlist_del() modifies this pointer using a marked write (WRITE_ONCE). Because proc_inode_is_dead() does not use !pid_has_task() or hlist_empty() (which perform a READ_ONCE), KCSAN reports a data race between detach_pid() and pid_delete_dentry().

▶ ▼ ✨ Full AI root cause analysis
Based on kernel commit 63fdb511c27a:

Technical Analysis of KCSAN Data-Race in detach_pid / pid_delete_dentry

1. Functions, Structs, and Files Involved

  • Write side:
    • File: kernel/pid.c, include/linux/list.h, kernel/exit.c
    • Functions: release_task() $\to$ __exit_signal() $\to$ __unhash_process() $\to$ detach_pid() $\to$ __change_pid() $\to$ hlist_del_rcu() $\to$ __hlist_del()
    • Field: pid->tasks[PIDTYPE_PID].first (a struct hlist_node * within struct pid).
  • Read side:
    • File: fs/proc/base.c, fs/dcache.c
    • Functions: dput() $\to$ finish_dput() $\to$ retain_dentry() $\to$ pid_delete_dentry() $\to$ proc_inode_is_dead() (also called from proc_task_readdir())
    • Field: proc_pid(inode)->tasks[PIDTYPE_PID].first.

2. Root Cause and Mechanism

  1. Write Path (detach_pid): When a task is reaped (e.g., via wait4() calling wait_task_zombie() $\to$ release_task()), release_task() acquires write_lock_irq(&tasklist_lock) and calls __exit_signal(). In __unhash_process(), the task's thread PID is detached via detach_pid(post->pids, p, PIDTYPE_PID), which calls __change_pid(). __change_pid() removes the task's link using hlist_del_rcu(&task->pid_links[type]). In __hlist_del(), the list head pointer is cleared via:

    WRITE_ONCE(*pprev, next);
    

    When the detached task is the head of the list, *pprev points to pid->tasks[PIDTYPE_PID].first. This write is explicitly marked with WRITE_ONCE.

  2. Read Path (pid_delete_dentry): In procfs, dentries representing /proc/<pid> or its descendants use pid_dentry_operations, where .d_delete is assigned to pid_delete_dentry(). When any dentry is released via dput() (for instance, when unhashing dentries during proc_flush_pid() or on standard file close / dentry eviction), finish_dput() invokes retain_dentry(), which checks dentry->d_op->d_delete(dentry):

    int pid_delete_dentry(const struct dentry *dentry)
    {
        return proc_inode_is_dead(d_inode(dentry));
    }
    

    In fs/proc/base.c:

    static inline bool proc_inode_is_dead(struct inode *inode)
    {
        return !proc_pid(inode)->tasks[PIDTYPE_PID].first;
    }
    

    retain_dentry() and pid_delete_dentry() execute without holding tasklist_lock.

  3. The Invariant / Concurrency Violation: proc_inode_is_dead() reads proc_pid(inode)->tasks[PIDTYPE_PID].first using a plain, unmarked memory access. Everywhere else in the kernel where lockless checks for active tasks on a struct pid are performed (such as pidfd_show_fdinfo(), show_timer(), posix cpu timers, or pidfd_prepare()), the kernel uses:

    pid_has_task(pid, type);
    

    defined in include/linux/pid.h:

    static inline bool pid_has_task(struct pid *pid, enum pid_type type)
    {
        return !hlist_empty(&pid->tasks[type]);
    }
    

    which invokes hlist_empty() (include/linux/list.h):

    static inline int hlist_empty(const struct hlist_head *h)
    {
        return !READ_ONCE(h->first);
    }
    

    Because proc_inode_is_dead() open-codes the empty check rather than calling !pid_has_task(proc_pid(inode), PIDTYPE_PID) (or using READ_ONCE()), an unmarked read races with the concurrent WRITE_ONCE() in detach_pid(), triggering the KCSAN data-race report.

▶ ▼ ✨ AI Jobs (3)
ID Workflow Result Correct Bug Created Started Finished Revision
eea1299b assessment-kcsan Benign: ✅ ❓ KCSAN: data-race in detach_pid / pid_delete_dentry 2026/11/17 23:38 2026/11/17 23:38 2026/11/17 23:55 ca622473
a026d98e bisect-cause ❓ KCSAN: data-race in detach_pid / pid_delete_dentry 2026/11/17 23:33 2026/11/17 23:33 2026/11/18 00:21 ca622473
f298e24f assessment-security DenialOfService: ❌ Exploitable: ❌ FilesystemTrigger: ❌ FuzzingArtifact: ❌ MemoryCorruption: ❌ NetworkNeedsSetup: ❌ NetworkTrigger: ❌ PeripheralTrigger: ❌ RemoteTrigger: ❌ Unprivileged: ✅ UserNamespace: ✅ VMGuestTrigger: ❌ VMHostTrigger: ❌ ❓ KCSAN: data-race in detach_pid / pid_delete_dentry 2026/11/17 23:32 2026/11/17 23:32 2026/11/17 23:37 ca622473

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

write (marked) to 0xffff888103b557b0 of 8 bytes by task 4891 on cpu 1:
 __hlist_del include/linux/list.h:1045 [inline]
 hlist_del_rcu include/linux/rculist.h:599 [inline]
 __change_pid kernel/pid.c:413 [inline]
 detach_pid+0xb1/0x1a0 kernel/pid.c:426
 __unhash_process kernel/exit.c:141 [inline]
 __exit_signal kernel/exit.c:206 [inline]
 release_task+0x67e/0xba0 kernel/exit.c:267
 wait_task_zombie kernel/exit.c:1285 [inline]
 wait_consider_task+0x1131/0x1630 kernel/exit.c:1512
 do_wait_thread kernel/exit.c:1575 [inline]
 __do_wait+0xf1/0x500 kernel/exit.c:1693
 do_wait+0xc9/0x2c0 kernel/exit.c:1727
 kernel_wait4+0x19f/0x210 kernel/exit.c:1886
 __do_sys_wait4 kernel/exit.c:1914 [inline]
 __se_sys_wait4 kernel/exit.c:1910 [inline]
 __x64_sys_wait4+0x91/0x120 kernel/exit.c:1910
 x64_sys_call+0x108f/0x2550 arch/x86/include/generated/asm/syscalls_64.h:62
 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

read to 0xffff888103b557b0 of 8 bytes by task 5277 on cpu 0:
 proc_inode_is_dead fs/proc/base.c:2067 [inline]
 pid_delete_dentry+0x30/0x50 fs/proc/base.c:2076
 retain_dentry fs/dcache.c:913 [inline]
 finish_dput+0xd8/0x1d0 fs/dcache.c:1033
 dput+0x43/0x50 fs/dcache.c:1073
 proc_invalidate_siblings_dcache+0x1e6/0x2c0 fs/proc/inode.c:143
 proc_flush_pid+0x1d/0x30 fs/proc/base.c:3457
 release_task+0xa0c/0xba0 kernel/exit.c:292
 exit_notify kernel/exit.c:781 [inline]
 do_exit+0xd64/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: 0xffff88810463ede8 -> 0x0000000000000000

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

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2026/11/17 23:24 upstream 63fdb511c27a 122f94d5 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in detach_pid / pid_delete_dentry
* Struck through repros no longer work on HEAD.