[moderation] [fs?] KCSAN: data-race in inode_update_timestamps / inode_update_timestamps (5)

4 views
Skip to first unread message

syzbot

unread,
Nov 30, 2025, 4:04:31 PM (2 days ago) Nov 30
to syzkaller-upst...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: e69c7c175115 Merge tag 'timers_urgent_for_v6.18_rc8' of gi..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=16894512580000
kernel config: https://syzkaller.appspot.com/x/.config?x=655255e3ef31c19b
dashboard link: https://syzkaller.appspot.com/bug?extid=c8180013497827bbb437
compiler: Debian clang version 20.1.8 (++20250708063551+0c9f909b7976-1~exp1~20250708183702.136), Debian LLD 20.1.8
CC: [linux-...@vger.kernel.org linux-...@vger.kernel.org]

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

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/04640737f2d9/disk-e69c7c17.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/4626b4f723cf/vmlinux-e69c7c17.xz
kernel image: https://storage.googleapis.com/syzbot-assets/ec1d58093b2b/bzImage-e69c7c17.xz

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

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

write to 0xffff888104e529a4 of 4 bytes by task 2408 on cpu 0:
inode_set_mtime_to_ts include/linux/fs.h:1839 [inline]
inode_update_timestamps+0x147/0x270 fs/inode.c:2075
generic_update_time fs/inode.c:2110 [inline]
inode_update_time fs/inode.c:2130 [inline]
__file_update_time fs/inode.c:2357 [inline]
file_update_time+0x20e/0x2b0 fs/inode.c:2387
fault_dirty_shared_page+0xd9/0x3c0 mm/memory.c:3531
do_shared_fault mm/memory.c:5808 [inline]
do_fault mm/memory.c:5854 [inline]
do_pte_missing mm/memory.c:4362 [inline]
handle_pte_fault mm/memory.c:6195 [inline]
__handle_mm_fault mm/memory.c:6336 [inline]
handle_mm_fault+0x165d/0x2be0 mm/memory.c:6505
do_user_addr_fault+0x3fe/0x1080 arch/x86/mm/fault.c:1387
handle_page_fault arch/x86/mm/fault.c:1476 [inline]
exc_page_fault+0x62/0xa0 arch/x86/mm/fault.c:1532
asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:618
rep_movs_alternative+0x4a/0x90 arch/x86/lib/copy_user_64.S:68
copy_user_generic arch/x86/include/asm/uaccess_64.h:126 [inline]
raw_copy_to_user arch/x86/include/asm/uaccess_64.h:147 [inline]
_inline_copy_to_user include/linux/uaccess.h:197 [inline]
_copy_to_user+0x7c/0xa0 lib/usercopy.c:26
copy_to_user include/linux/uaccess.h:225 [inline]
pagemap_read+0x379/0x5e0 fs/proc/task_mmu.c:2254
vfs_read+0x1a8/0x770 fs/read_write.c:570
ksys_pread64 fs/read_write.c:763 [inline]
__do_sys_pread64 fs/read_write.c:771 [inline]
__se_sys_pread64 fs/read_write.c:768 [inline]
__x64_sys_pread64+0xfd/0x150 fs/read_write.c:768
x64_sys_call+0x29e6/0x3000 arch/x86/include/generated/asm/syscalls_64.h:18
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xd2/0x200 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f

read to 0xffff888104e529a4 of 4 bytes by task 2407 on cpu 1:
inode_get_mtime_nsec include/linux/fs.h:1825 [inline]
inode_get_mtime include/linux/fs.h:1831 [inline]
inode_update_timestamps+0x74/0x270 fs/inode.c:2069
generic_update_time fs/inode.c:2110 [inline]
inode_update_time fs/inode.c:2130 [inline]
__file_update_time fs/inode.c:2357 [inline]
file_update_time+0x20e/0x2b0 fs/inode.c:2387
fault_dirty_shared_page+0xd9/0x3c0 mm/memory.c:3531
do_shared_fault mm/memory.c:5808 [inline]
do_fault mm/memory.c:5854 [inline]
do_pte_missing mm/memory.c:4362 [inline]
handle_pte_fault mm/memory.c:6195 [inline]
__handle_mm_fault mm/memory.c:6336 [inline]
handle_mm_fault+0x165d/0x2be0 mm/memory.c:6505
do_user_addr_fault+0x630/0x1080 arch/x86/mm/fault.c:1336
handle_page_fault arch/x86/mm/fault.c:1476 [inline]
exc_page_fault+0x62/0xa0 arch/x86/mm/fault.c:1532
asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:618

value changed: 0x36a7a38f -> 0x37c5231d

Reported by Kernel Concurrency Sanitizer on:
CPU: 1 UID: 0 PID: 2407 Comm: syz.5.21554 Not tainted syzkaller #0 PREEMPT(voluntary)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/02/2025
==================================================================


---
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

Arnav Kapoor

unread,
Dec 1, 2025, 3:51:53 AM (yesterday) Dec 1
to syzkaller-upstream-moderation
#syz fix: fs: use READ_ONCE/WRITE_ONCE for inode timestamp accessors to avoid benign KCSAN races

From f11640680f4c8b4f11b1c46b44a93ab81c69d751 Mon Sep 17 00:00:00 2001
From: Arnav Kapoor <kapoor...@gmail.com>
Date: Mon, 1 Dec 2025 12:23:07 +0530
Subject: [PATCH] fs: use READ_ONCE/WRITE_ONCE for inode timestamp accessors to
 avoid benign KCSAN races

Reported-by: syzbot+c81800...@syzkaller.appspotmail.com
Signed-off-by: Arnav Kapoor <kapoor...@gmail.com>
---
 include/linux/fs.h | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/include/linux/fs.h b/include/linux/fs.h
index dd3b57cfa..53f9e8282 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1782,12 +1782,12 @@ struct timespec64 inode_set_ctime_deleg(struct inode *inode,
 
 static inline time64_t inode_get_atime_sec(const struct inode *inode)
 {
- return inode->i_atime_sec;
+ return READ_ONCE(inode->i_atime_sec);
 }
 
 static inline long inode_get_atime_nsec(const struct inode *inode)
 {
- return inode->i_atime_nsec;
+ return READ_ONCE(inode->i_atime_nsec);
 }
 
 static inline struct timespec64 inode_get_atime(const struct inode *inode)
@@ -1801,8 +1801,8 @@ static inline struct timespec64 inode_get_atime(const struct inode *inode)
 static inline struct timespec64 inode_set_atime_to_ts(struct inode *inode,
        struct timespec64 ts)
 {
- inode->i_atime_sec = ts.tv_sec;
- inode->i_atime_nsec = ts.tv_nsec;
+ WRITE_ONCE(inode->i_atime_sec, ts.tv_sec);
+ WRITE_ONCE(inode->i_atime_nsec, ts.tv_nsec);
  return ts;
 }
 
@@ -1817,12 +1817,12 @@ static inline struct timespec64 inode_set_atime(struct inode *inode,
 
 static inline time64_t inode_get_mtime_sec(const struct inode *inode)
 {
- return inode->i_mtime_sec;
+ return READ_ONCE(inode->i_mtime_sec);
 }
 
 static inline long inode_get_mtime_nsec(const struct inode *inode)
 {
- return inode->i_mtime_nsec;
+ return READ_ONCE(inode->i_mtime_nsec);
 }
 
 static inline struct timespec64 inode_get_mtime(const struct inode *inode)
@@ -1835,8 +1835,8 @@ static inline struct timespec64 inode_get_mtime(const struct inode *inode)
 static inline struct timespec64 inode_set_mtime_to_ts(struct inode *inode,
        struct timespec64 ts)
 {
- inode->i_mtime_sec = ts.tv_sec;
- inode->i_mtime_nsec = ts.tv_nsec;
+ WRITE_ONCE(inode->i_mtime_sec, ts.tv_sec);
+ WRITE_ONCE(inode->i_mtime_nsec, ts.tv_nsec);
  return ts;
 }
 
@@ -1861,12 +1861,12 @@ static inline struct timespec64 inode_set_mtime(struct inode *inode,
 
 static inline time64_t inode_get_ctime_sec(const struct inode *inode)
 {
- return inode->i_ctime_sec;
+ return READ_ONCE(inode->i_ctime_sec);
 }
 
 static inline long inode_get_ctime_nsec(const struct inode *inode)
 {
- return inode->i_ctime_nsec & ~I_CTIME_QUERIED;
+ return READ_ONCE(inode->i_ctime_nsec) & ~I_CTIME_QUERIED;
 }
 
 static inline struct timespec64 inode_get_ctime(const struct inode *inode)
--
2.43.0
Reply all
Reply to author
Forward
0 new messages