KCSAN: data-race in proc_invalidate_siblings_dcache / proc_pid_evict_inode

Status: moderation: reported on 2026/11/27 07:28
Subsystems: fs
Labels: prio:low race:harmful
[Documentation on labels]
Reported-by: syzbot+627a667e74583abd894f@syzkaller.appspotmail.com
First crash: 32m, last: 32m
✨ AI-generated root cause summary:

proc_invalidate_siblings_dcache() in fs/proc/inode.c reads the RCU-protected hlist head using hlist_first_rcu(inodes) directly without wrapping it in rcu_dereference() (or holding the list spinlock). Because hlist_first_rcu() is a plain pointer dereference rather than an atomic/RCU load, this creates an unmarked read on pid->inodes.first that races with marked writes (WRITE_ONCE(*pprev, next)) in __hlist_del() when proc_pid_evict_inode() unlinks a sibling inode under pid->lock.

▶ ▼ ✨ Full AI root cause analysis
Based on kernel commit 9437ee8b6cf6:

Root Cause

The data race is caused by an unmarked read of inodes->first in proc_invalidate_siblings_dcache() (fs/proc/inode.c:114):

	rcu_read_lock();
	while ((node = hlist_first_rcu(inodes))) {
		struct proc_inode *ei = hlist_entry(node, struct proc_inode, sibling_inodes);
		...
		spin_lock(lock);
		hlist_del_init_rcu(&ei->sibling_inodes);
		spin_unlock(lock);

In include/linux/rculist.h:649, hlist_first_rcu() is defined as an lvalue/pointer expression rather than an RCU load primitive:

#define hlist_first_rcu(head)	(*((struct hlist_node __rcu **)(&(head)->first)))

It is meant to be passed to rcu_dereference() / rcu_dereference_raw() (for reads) or rcu_assign_pointer() (for writes). Calling hlist_first_rcu(inodes) directly without rcu_dereference() and without holding lock performs a plain, unmarked read of inodes->first.

Triggering Mechanism

  1. Multiple struct proc_inode directory entries associated with a struct pid (e.g., /proc/<tgid> or /proc/<tgid>/task/<tid>) are linked into pid->inodes via ei->sibling_inodes (proc_pid_make_base_inode() in fs/proc/base.c:1991), protected by pid->lock.
  2. During task teardown (release_task() -> proc_flush_pid() in fs/proc/base.c:3457), proc_invalidate_siblings_dcache(&pid->inodes, &pid->lock) is called to invalidate and drop cached dentries for all sibling proc inodes on pid->inodes.
  3. Concurrently, another task evicts a proc directory inode referencing the same pid (in this trace, task 6951 in proc_invalidate_siblings_dcache() -> dput(dir) triggers parent dentry/inode eviction down to proc_evict_inode() -> proc_pid_evict_inode() in fs/proc/base.c:1918). proc_pid_evict_inode() acquires spin_lock(&pid->lock) and calls hlist_del_init_rcu(&ei->sibling_inodes) -> __hlist_del() (include/linux/list.h:1045), which updates *pprev (pid->inodes.first when deleting the head element) via WRITE_ONCE(*pprev, next).
  4. At the same time, task 5112 (in wait_task_zombie() -> release_task() -> proc_flush_pid() -> proc_invalidate_siblings_dcache()) reads pid->inodes.first via the unmarked hlist_first_rcu(inodes) at fs/proc/inode.c:114 without holding pid->lock, causing KCSAN to report a data race between the marked write in __hlist_del() and the unmarked read in proc_invalidate_siblings_dcache(). (The same pattern also applies to proc_sys_invalidate_dcache() / proc_sys_evict_inode() in fs/proc/proc_sysctl.c using sysctl_lock.)

Invariant / Fix Context

proc_invalidate_siblings_dcache() holds rcu_read_lock() across the list-head read until after igrab(&ei->vfs_inode), and proc_inode is freed via RCU (destroy_inode() -> call_rcu(&inode->i_rcu, i_callback) -> proc_free_inode()), while list mutations are serialized by spin_lock(lock). Using rcu_dereference(hlist_first_rcu(inodes)) (or reading inodes->first inside spin_lock(lock) directly, as the loop already acquires lock on every iteration) eliminates the unmarked read and satisfies RCU/KCSAN rules.

▶ ▼ ✨ AI Jobs (2)
ID Workflow Result Correct Bug Created Started Finished Revision
a45a9d8a assessment-kcsan Benign: ❌ ❓ KCSAN: data-race in proc_invalidate_siblings_dcache / proc_pid_evict_inode 2026/11/27 07:20 2026/11/27 07:20 2026/11/27 07:28 f1f6b8bf
b3db39e9 assessment-security DenialOfService: ❌ Exploitable: ❌ FilesystemTrigger: ❌ FuzzingArtifact: ❌ MemoryCorruption: ❌ NetworkNeedsSetup: ❌ NetworkTrigger: ❌ PeripheralTrigger: ❌ RemoteTrigger: ❌ Unprivileged: ✅ UserNamespace: ✅ VMGuestTrigger: ❌ VMHostTrigger: ❌ ❓ KCSAN: data-race in proc_invalidate_siblings_dcache / proc_pid_evict_inode 2026/11/27 07:20 2026/11/27 07:20 2026/11/27 07:23 f1f6b8bf

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

write (marked) to 0xffff8881048a01d0 of 8 bytes by task 6951 on cpu 0:
 __hlist_del include/linux/list.h:1045 [inline]
 hlist_del_init_rcu include/linux/rculist.h:238 [inline]
 proc_pid_evict_inode+0x7c/0xd0 fs/proc/base.c:1918
 proc_evict_inode+0x45/0xa0 fs/proc/inode.c:41
 evict+0x301/0x570 fs/inode.c:829
 iput_final fs/inode.c:2036 [inline]
 iput+0x44f/0x5d0 fs/inode.c:2085
 dentry_unlink_inode+0x29a/0x2b0 fs/dcache.c:510
 dentry_kill+0x135/0x4f0 fs/dcache.c:857
 finish_dput+0x9f/0x1d0 fs/dcache.c:1032
 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

read to 0xffff8881048a01d0 of 8 bytes by task 5112 on cpu 1:
 proc_invalidate_siblings_dcache+0x2a/0x2c0 fs/proc/inode.c:114
 proc_flush_pid+0x1d/0x30 fs/proc/base.c:3457
 release_task+0xa0c/0xba0 kernel/exit.c:292
 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

value changed: 0xffff8881071611b0 -> 0xffff88810718e530

Reported by Kernel Concurrency Sanitizer on:
CPU: 1 UID: 0 PID: 5112 Comm: syz-executor 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/27 07:20 upstream 9437ee8b6cf6 f1f6b8bf .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in proc_invalidate_siblings_dcache / proc_pid_evict_inode
* Struck through repros no longer work on HEAD.