lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241028181922.406204-1-danielyangkang@gmail.com>
Date: Mon, 28 Oct 2024 11:19:22 -0700
From: Daniel Yang <danielyangkang@...il.com>
To: OGAWA Hirofumi <hirofumi@...l.parknet.co.jp>,
	linux-kernel@...r.kernel.org (open list)
Cc: Daniel Yang <danielyangkang@...il.com>,
	syzbot+0dd28f0c6293cc87d462@...kaller.appspotmail.com
Subject: [PATCH] Fix BUG: KCSAN: data-race in xas_find_marked / xas_init_marks

The cause of the bug is a call to truncate_setsize() while
fat_file_fsync() is attempting to read. Although fat_setattr() acquires
&MSDOS_I(inode)->truncate_lock before calling truncate, fat_file_fsync()
doesn't acquire the read lock for truncate_lock. The function
__generic_file_fsync() called in fat_file_fsync() only acquires lock to
the inode itself, not the &MSDOS_I(inode) it is a member of. This leads
to the data race where fat_file_fsync is reading during truncation.

To fix: &MSDOS_I(inode)->truncate_lock is acquired for reading before
calling __generic_file_fsync().

Signed-off-by: Daniel Yang <danielyangkang@...il.com>
Reported-by: syzbot+0dd28f0c6293cc87d462@...kaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=0dd28f0c6293cc87d462
---
 fs/fat/file.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/fat/file.c b/fs/fat/file.c
index e887e9ab7..5578b771a 100644
--- a/fs/fat/file.c
+++ b/fs/fat/file.c
@@ -188,7 +188,9 @@ int fat_file_fsync(struct file *filp, loff_t start, loff_t end, int datasync)
 	struct inode *inode = filp->f_mapping->host;
 	int err;
 
+	down_read(&MSDOS_I(inode)->truncate_lock);
 	err = __generic_file_fsync(filp, start, end, datasync);
+	up_read(&MSDOS_I(inode)->truncate_lock);
 	if (err)
 		return err;
 
-- 
2.39.2


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ