KCSAN: data-race in generic_fillattr / shmem_mknod (2)
Subsystems (2)
#syz test git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
--- mm/shmem.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
mm/shmem.c +7 -5
@@ -1154,7 +1154,9 @@ static int shmem_getattr(struct mnt_idmap *idmap, stat->attributes_mask |= (STATX_ATTR_APPEND |STATX_ATTR_IMMUTABLE |STATX_ATTR_NODUMP ); +inode_lock_shared (inode);generic_fillattr (idmap, request_mask, inode, stat); +inode_unlock_shared (inode);if (shmem_is_huge (inode,0 , false,NULL ,0 )) stat->blksize =HPAGE_PMD_SIZE ;
@@ -3439,7 +3441,7 @@ shmem_mknod(struct mnt_idmap *idmap, struct inode *dir,if (error) goto out_iput; - dir->i_size +=BOGO_DIRENT_SIZE ; +i_size_write (dir,i_size_read (dir) +BOGO_DIRENT_SIZE );inode_set_mtime_to_ts (dir,inode_set_ctime_current (dir));inode_inc_iversion (dir);d_instantiate (dentry, inode);
@@ -3526,7 +3528,7 @@ static int shmem_link(struct dentry *old_dentry, struct inode *dir, goto out; } - dir->i_size +=BOGO_DIRENT_SIZE ; +i_size_write (dir,i_size_read (dir) +BOGO_DIRENT_SIZE );inode_set_mtime_to_ts (dir,inode_set_ctime_to_ts (dir,inode_set_ctime_current (inode)));inode_inc_iversion (dir);
@@ -3639,8 +3641,8 @@ static int shmem_rename2(struct mnt_idmap *idmap,inc_nlink (new_dir); } - old_dir->i_size -=BOGO_DIRENT_SIZE ; - new_dir->i_size +=BOGO_DIRENT_SIZE ; +i_size_write (old_dir,i_size_read (old_dir) -BOGO_DIRENT_SIZE ); +i_size_write (new_dir,i_size_read (new_dir) +BOGO_DIRENT_SIZE );simple_rename_timestamp (old_dir, old_dentry, new_dir, new_dentry);inode_inc_iversion (old_dir);inode_inc_iversion (new_dir);
@@ -3694,7 +3696,7 @@ static int shmem_symlink(struct mnt_idmap *idmap, struct inode *dir,folio_unlock (folio);folio_put (folio); } - dir->i_size +=BOGO_DIRENT_SIZE ; +i_size_write (dir,i_size_read (dir) +BOGO_DIRENT_SIZE );inode_set_mtime_to_ts (dir,inode_set_ctime_current (dir));inode_inc_iversion (dir);d_instantiate (dentry, inode);
--
syzbot
syzbotsyzbot has tested the proposed patch but the reproducer is still triggering an issue: KCSAN: data-race in ext4_free_inodes_count / ext4_free_inodes_set
Hello,
syzbot has tested the proposed patch but the reproducer is still triggering an issue:
KCSAN: data-race in ext4_free_inodes_count / ext4_free_inodes_set
==================================================================
BUG: KCSAN: data-race in ext4_free_inodes_count / ext4_free_inodes_set
write to 0xffff888103fc500e of 2 bytes by task 13551 on cpu 0:
ext4_free_inodes_set+0x1f/0x80 fs/ext4/super.c:405 __ext4_new_inode+0x15ca/0x2200 fs/ext4/ialloc.c:1216 ext4_symlink+0x242/0x5a0 fs/ext4/namei.c:3391 vfs_symlink+0xca/0x1d0 fs/namei.c:4568 do_symlinkat+0xe3/0x340 fs/namei.c:4594 __do_sys_symlinkat fs/namei.c:4610 [inline] __se_sys_symlinkat fs/namei.c:4607 [inline] __x64_sys_symlinkat+0x5e/0x70 fs/namei.c:4607 x64_sys_call+0x1dda/0x2d60 arch/x86/include/generated/asm/syscalls_64.h:267 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0x54/0x120 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x76/0x7e
read to 0xffff888103fc500e of 2 bytes by task 13552 on cpu 1:
ext4_free_inodes_count+0x1c/0x80 fs/ext4/super.c:349 find_group_other fs/ext4/ialloc.c:594 [inline] __ext4_new_inode+0x6ec/0x2200 fs/ext4/ialloc.c:1017 ext4_symlink+0x242/0x5a0 fs/ext4/namei.c:3391 vfs_symlink+0xca/0x1d0 fs/namei.c:4568 do_symlinkat+0xe3/0x340 fs/namei.c:4594 __do_sys_symlinkat fs/namei.c:4610 [inline] __se_sys_symlinkat fs/namei.c:4607 [inline] __x64_sys_symlinkat+0x5e/0x70 fs/namei.c:4607 x64_sys_call+0x1dda/0x2d60 arch/x86/include/generated/asm/syscalls_64.h:267 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0x54/0x120 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x76/0x7e
value changed: 0x185c -> 0x185b
Reported by Kernel Concurrency Sanitizer on:
CPU: 1 UID: 0 PID: 13552 Comm: syz-executor.1 Not tainted 6.11.0-rc6-syzkaller-00326-gd1f2d51b711a-dirty #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/06/2024 ==================================================================
Tested on:
commit: d1f2d51b Merge tag 'clk-fixes-for-linus' of git://git... git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=17ffef29980000 kernel config: https://syzkaller.appspot.com/x/.config?x=e81d40b0108ea8fe dashboard link: https://syzkaller.appspot.com/bug?extid=702361cf7e3d95758761 compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40 patch: https://syzkaller.appspot.com/x/patch.diff?x=17d10e00580000