syzbot
KCSAN: data-race in kernfs_fop_open / kernfs_iop_getattr
Status:
moderation: reported on 2026/11/18 02:03
Subsystems:
kernfs
Labels:
race:benign
prio:low
[Documentation on labels]
Reported-by: syzbot+727cca66b8415e905029@syzkaller.appspotmail.com
First crash: 16h16m, last: 16h16m
✨ AI-generated root cause summary:
In kernfs, VFS inode attributes are refreshed from the underlying kernfs_node (kn). During stat/fstat (kernfs_iop_getattr), kernfs acquires root->kernfs_iattr_rwsem in shared read mode and unconditionally executes an unmarked plain store (inode->i_mode = kn->mode) in kernfs_refresh_inode(). Concurrently, kernfs_fop_open() executes an unmarked plain read of inode->i_mode to perform DAC permission checks under KERNFS_ROOT_EXTRA_OPEN_PERM_CHECK (used by sysfs and resctrl) without holding root->kernfs_iattr_rwsem. Because neither side uses synchronization locks or READ_ONCE()/WRITE_ONCE() access annotations, KCSAN detects a data race on inode->i_mode.
▶
▼
✨ Full AI root cause analysis
Root Cause Analysis: Data-Race in kernfs_fop_open / kernfs_iop_getattr
1. Functions, Structs, and Files Involved
fs/kernfs/inode.c:
kernfs_refresh_inode() (lines 165–180): Refreshes VFS inode attributes from the underlying struct kernfs_node.
kernfs_iop_getattr() (lines 182–196): inode_operations->getattr implementation for kernfs inodes.
fs/kernfs/file.c:
kernfs_fop_open() (lines 617–645): file_operations->open implementation for kernfs files.
include/linux/fs.h & include/linux/kernfs.h:
struct inode::i_mode: 16-bit (umode_t) permission and file-type field.
struct kernfs_node::mode: Canonical file mode and permissions stored in the kernfs hierarchy.
struct kernfs_root::flags: Flags such as KERNFS_ROOT_EXTRA_OPEN_PERM_CHECK used by filesystems like sysfs and resctrl.
2. Technical Mechanism and Trigger Conditions
-
Write Side (fs/kernfs/inode.c via stat / fstat):
-
Read Side (fs/kernfs/file.c via open / openat):
-
Concurrency Conflict:
- Because neither the store in
kernfs_refresh_inode() nor the load in kernfs_fop_open() is guarded by a common mutual exclusion lock or marked with compiler barriers (READ_ONCE() / WRITE_ONCE()), concurrent execution on separate CPU cores triggers the KCSAN data-race report on &inode->i_mode.
Sample crash report:
* Struck through repros no longer work on HEAD.