[moderation] [kernfs?] KCSAN: data-race in kernfs_iop_permission / kernfs_iop_permission (10)

0 views
Skip to first unread message

syzbot

unread,
7:03 PM (1 hour ago) 7:03 PM
to syzkaller-upst...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 8dac6df92a2e Merge tag 'nfsd-7.4-1' of git://git.kernel.or..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=10bc1363580000
kernel config: https://syzkaller.appspot.com/x/.config?x=886d2ddd2d6b664e
dashboard link: https://syzkaller.appspot.com/bug?extid=2bce1dc5756d528a637b
compiler: Debian clang version 22.1.8 (1~deb13u4), Debian LLD 22.1.8
CC: [drive...@lists.linux.dev gre...@linuxfoundation.org linux-...@vger.kernel.org t...@kernel.org]

Unfortunately, I don't have any reproducer for this issue yet.

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/dfc787d10469/disk-8dac6df9.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/db7a8e4799da/vmlinux-8dac6df9.xz
kernel image: https://storage.googleapis.com/syzbot-assets/169073a123bc/bzImage-8dac6df9.xz

AI-generated root cause summary:
In fs/kernfs/inode.c, kernfs_iop_permission() (and likewise
kernfs_iop_getattr()) acquires root->kernfs_iattr_rwsem only as a shared reader
via down_read() before calling kernfs_refresh_inode(kn, inode). However,
kernfs_refresh_inode() mutates fields of the VFS struct inode—specifically
writing inode->i_mode, uid/gid, timestamps, and i_nlink—to synchronize them with
the persistent attributes on struct kernfs_node. Because VFS path lookup calls
inode_operations->permission() (and getattr()) without holding an exclusive
inode lock, multiple tasks traversing or stat'ing the same kernfs inode
concurrently enter kernfs_iop_permission() in parallel under down_read(). This
causes concurrent unsynchronized writes to inode->i_mode (offset 0 of struct
inode, 2 bytes) and the other refreshed inode metadata fields, triggering the
KCSAN data-race report.

full analysis: https://syzkaller.appspot.com/x/ai_root_cause?x=2bce1dc5756d528a637b

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+2bce1d...@syzkaller.appspotmail.com

==================================================================
BUG: KCSAN: data-race in kernfs_iop_permission / kernfs_iop_permission

write to 0xffff88810051c000 of 2 bytes by task 3319 on cpu 1:
kernfs_refresh_inode fs/kernfs/inode.c:169 [inline]
kernfs_iop_permission+0x9d/0x220 fs/kernfs/inode.c:287
do_inode_permission fs/namei.c:583 [inline]
inode_permission+0x2b4/0x3c0 fs/namei.c:653
lookup_inode_permission_may_exec fs/namei.c:-1 [inline]
may_lookup fs/namei.c:1982 [inline]
link_path_walk+0xadb/0xde0 fs/namei.c:2610
path_lookupat+0x53/0x4c0 fs/namei.c:2818
filename_lookup+0x18f/0x390 fs/namei.c:2848
vfs_statx+0x96/0x170 fs/stat.c:357
vfs_fstatat+0x118/0x170 fs/stat.c:377
__do_sys_newfstatat fs/stat.c:542 [inline]
__se_sys_newfstatat+0x55/0x3e0 fs/stat.c:536
__x64_sys_newfstatat+0x55/0x70 fs/stat.c:536
x64_sys_call+0xee6/0x2550 arch/x86/include/generated/asm/syscalls_64.h:263
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

write to 0xffff88810051c000 of 2 bytes by task 3015 on cpu 0:
kernfs_refresh_inode fs/kernfs/inode.c:169 [inline]
kernfs_iop_permission+0x9d/0x220 fs/kernfs/inode.c:287
do_inode_permission fs/namei.c:583 [inline]
inode_permission+0x2b4/0x3c0 fs/namei.c:653
lookup_inode_permission_may_exec fs/namei.c:-1 [inline]
may_lookup fs/namei.c:1982 [inline]
link_path_walk+0xadb/0xde0 fs/namei.c:2610
path_lookupat+0x53/0x4c0 fs/namei.c:2818
filename_lookup+0x18f/0x390 fs/namei.c:2848
vfs_statx+0x96/0x170 fs/stat.c:357
vfs_fstatat+0x118/0x170 fs/stat.c:377
__do_sys_newfstatat fs/stat.c:542 [inline]
__se_sys_newfstatat+0x55/0x3e0 fs/stat.c:536
__x64_sys_newfstatat+0x55/0x70 fs/stat.c:536
x64_sys_call+0xee6/0x2550 arch/x86/include/generated/asm/syscalls_64.h:263
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

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


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup
Reply all
Reply to author
Forward
0 new messages