[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240908052338.7283-1-aha310510@gmail.com>
Date: Sun, 8 Sep 2024 14:23:38 +0900
From: Jeongjun Park <aha310510@...il.com>
To: syzbot+702361cf7e3d95758761@...kaller.appspotmail.com
Cc: linux-kernel@...r.kernel.org,
syzkaller-bugs@...glegroups.com
Subject: Re: KCSAN: data-race in generic_fillattr / shmem_mknod (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(-)
diff --git a/mm/shmem.c b/mm/shmem.c
index 5a77acf6ac6a..1595f6e7688c 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -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);
--
Powered by blists - more mailing lists