syzbot
KCSAN: data-race in task_dump_owner / task_dump_owner (2)
Status:
moderation: reported on 2026/11/23 02:36
Subsystems:
fs
Labels:
race:harmful
prio:low
[Documentation on labels]
Reported-by: syzbot+01225feba16a0f7227e3@syzkaller.appspotmail.com
First crash: 34m, last: 34m
✨ AI-generated root cause summary:
During concurrent VFS lookups of the same /proc/<pid> dentry, lookup_fast() invokes pid_revalidate() without holding any inode lock (including in RCU-walk mode). pid_revalidate() calls pid_update_inode(), which calls task_dump_owner(task, inode->i_mode, &inode->i_uid, &inode->i_gid). task_dump_owner() performs plain, unsynchronized 4-byte writes to inode->i_uid and inode->i_gid, causing concurrent writers across CPUs to race on the same struct inode fields.
▶
▼
✨ Full AI root cause analysis
Root Cause Analysis
The KCSAN data race occurs when multiple tasks concurrently traverse and revalidate the same /proc/<pid> dentry during VFS path lookup.
-
Unserialized Revalidation Path (fs/namei.c, fs/proc/base.c):
During openat() (do_sys_openat2() -> do_file_open() -> path_openat() -> link_path_walk() -> walk_component() -> lookup_fast()), the VFS calls d_revalidate() on cached dentries. For procfs task dentries using pid_dentry_operations, .d_revalidate is pid_revalidate() (fs/proc/base.c:2043).
Unlike tid_fd_revalidate() (fs/proc/fd.c:143) or map_files_d_revalidate() (fs/proc/base.c:2179), pid_revalidate() does not reject LOOKUP_RCU with -ECHILD, and even in non-RCU ref-walk mode d_revalidate() is invoked without holding inode->i_lock or inode->i_rwsem on the target inode:
rcu_read_lock();
inode = d_inode_rcu(dentry);
if (!inode)
goto out;
task = pid_task(proc_pid(inode), PIDTYPE_PID);
if (task) {
pid_update_inode(task, inode);
ret = 1;
}
-
Unsynchronized Writes to struct inode Ownership Fields (fs/proc/base.c):
pid_update_inode() (fs/proc/base.c:2030) refreshes the inode's ownership and mode in place:
void pid_update_inode(struct task_struct *task, struct inode *inode)
{
task_dump_owner(task, inode->i_mode, &inode->i_uid, &inode->i_gid);
inode->i_mode &= ~(S_ISUID | S_ISGID);
security_task_to_inode(task, inode);
}
Inside task_dump_owner() (fs/proc/base.c:1862), the computed kuid_t and kgid_t values are written with plain stores directly to *ruid (&inode->i_uid, 4 bytes at offset 24 in struct inode) and *rgid (&inode->i_gid, 4 bytes at offset 28) at lines 1873–1874 (PF_KTHREAD) or lines 1908–1909 (*ruid = uid; *rgid = gid;).
-
Concurrent Trigger:
When two CPUs simultaneously look up the same /proc/<pid> dentry (here tasks 6557 and 6556 executing openat()), both enter pid_revalidate() -> pid_update_inode() -> task_dump_owner() concurrently and perform unmarked 4-byte writes to the same inode->i_uid / inode->i_gid address (0xffff88811b422a60), triggering the data-race in task_dump_owner / task_dump_owner report.
Related Unsynchronized Sites
- In
pid_update_inode(), inode->i_mode is also read without READ_ONCE() and updated via an unsynchronized read-modify-write (inode->i_mode &= ~(S_ISUID | S_ISGID);).
- While
selinux_task_to_inode() takes isec->lock, other security_task_to_inode() hooks such as smack_task_to_inode() (security/smack/smack_lsm.c:2433) also mutate inode->i_security fields without locking.
- Similarly,
map_files_d_revalidate() (fs/proc/base.c:2213) and tid_fd_revalidate() -> tid_fd_update_inode() (fs/proc/fd.c:130) call task_dump_owner(task, 0, &inode->i_uid, &inode->i_gid) in ref-walk d_revalidate without per-inode locking, so they can also race under concurrent lookups.
Sample crash report:
* Struck through repros no longer work on HEAD.