RE: [syzbot] [exfat?] KMSAN: uninit-value in __exfat_get_dentry_set

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



#syz test

On Sat, Oct 5, 2024 at 8:02 PM syzbot <syzbot+01218003be74b5e1213a@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
> 
> Hello,
> 
> syzbot found the following issue on:
> 
> HEAD commit:    e32cde8d2bd7 Merge tag 'sched_ext-for-6.12-rc1-fixes-1'
> of..
> git tree:       upstream
> console+strace:
> https://urldefense.com/v3/__https://syzkaller.appspot.com/x/log.txt?x=16cf7d
> d0580000__;!!JmoZiZGBv3RvKRSx!_EFM31JxDI_sBC6NhWwWIWcja8UUVBXZY
> WyhK0O9vUuSsqy-ZOla4TuepNTA3X-btBmzePMIOD0CGeGE0kSF4M2hOwVy5
> 7mr5yQIbTA6$
> kernel config:
> https://urldefense.com/v3/__https://syzkaller.appspot.com/x/.config?x=b1fd45
> f2013d812f__;!!JmoZiZGBv3RvKRSx!_EFM31JxDI_sBC6NhWwWIWcja8UUVBX
> ZYWyhK0O9vUuSsqy-ZOla4TuepNTA3X-btBmzePMIOD0CGeGE0kSF4M2hOwV
> y57mr50IfSXOd$
> dashboard link:
> https://urldefense.com/v3/__https://syzkaller.appspot.com/bug?extid=012180
> 03be74b5e1213a__;!!JmoZiZGBv3RvKRSx!_EFM31JxDI_sBC6NhWwWIWcja8U
> UVBXZYWyhK0O9vUuSsqy-ZOla4TuepNTA3X-btBmzePMIOD0CGeGE0kSF4M2h
> OwVy57mr5-IoYOKx$
> compiler:       Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian)
> 2.40
> syz repro:
> https://urldefense.com/v3/__https://syzkaller.appspot.com/x/repro.syz?x=11cf
> 7dd0580000__;!!JmoZiZGBv3RvKRSx!_EFM31JxDI_sBC6NhWwWIWcja8UUVB
> XZYWyhK0O9vUuSsqy-ZOla4TuepNTA3X-btBmzePMIOD0CGeGE0kSF4M2hOw
> Vy57mr58TvVCus$
> C reproducer:
> https://urldefense.com/v3/__https://syzkaller.appspot.com/x/repro.c?x=11d06
> 580580000__;!!JmoZiZGBv3RvKRSx!_EFM31JxDI_sBC6NhWwWIWcja8UUVBXZ
> YWyhK0O9vUuSsqy-ZOla4TuepNTA3X-btBmzePMIOD0CGeGE0kSF4M2hOwVy
> 57mr5w2Sgp57$
> 
> Downloadable assets:
> disk image:
> https://urldefense.com/v3/__https://storage.googleapis.com/syzbot-assets/16
> d4da549bf4/disk-e32cde8d.raw.xz__;!!JmoZiZGBv3RvKRSx!_EFM31JxDI_sBC6
> NhWwWIWcja8UUVBXZYWyhK0O9vUuSsqy-ZOla4TuepNTA3X-btBmzePMIOD0
> CGeGE0kSF4M2hOwVy57mr54CRCyjy$
> vmlinux:
> https://urldefense.com/v3/__https://storage.googleapis.com/syzbot-assets/a01
> bc9a0e174/vmlinux-e32cde8d.xz__;!!JmoZiZGBv3RvKRSx!_EFM31JxDI_sBC6N
> hWwWIWcja8UUVBXZYWyhK0O9vUuSsqy-ZOla4TuepNTA3X-btBmzePMIOD0C
> GeGE0kSF4M2hOwVy57mr5_9fwsZ2$
> kernel image:
> https://urldefense.com/v3/__https://storage.googleapis.com/syzbot-assets/93f
> 4dfad6909/bzImage-e32cde8d.xz__;!!JmoZiZGBv3RvKRSx!_EFM31JxDI_sBC6N
> hWwWIWcja8UUVBXZYWyhK0O9vUuSsqy-ZOla4TuepNTA3X-btBmzePMIOD0C
> GeGE0kSF4M2hOwVy57mr54HU84Yj$
> mounted in repro:
> https://urldefense.com/v3/__https://storage.googleapis.com/syzbot-assets/43
> 3ba0700154/mount_0.gz__;!!JmoZiZGBv3RvKRSx!_EFM31JxDI_sBC6NhWwWI
> Wcja8UUVBXZYWyhK0O9vUuSsqy-ZOla4TuepNTA3X-btBmzePMIOD0CGeGE0k
> SF4M2hOwVy57mr51x55siW$
> 
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by:
> mailto:syzbot+01218003be74b5e1213a@xxxxxxxxxxxxxxxxxxxxxxxxx
> 
> exFAT-fs (loop0): failed to load upcase table (idx : 0x00010000, chksum :
> 0x726052d3, utbl_chksum : 0xe619d30d)
> =====================================================
> BUG: KMSAN: uninit-value in __exfat_get_dentry_set+0x10ca/0x14d0
> fs/exfat/dir.c:804
>  __exfat_get_dentry_set+0x10ca/0x14d0 fs/exfat/dir.c:804
>  exfat_get_dentry_set+0x58/0xec0 fs/exfat/dir.c:859
>  __exfat_write_inode+0x3c1/0xe30 fs/exfat/inode.c:46
>  __exfat_truncate+0x7f3/0xbb0 fs/exfat/file.c:211
>  exfat_truncate+0xee/0x2a0 fs/exfat/file.c:257
>  exfat_write_failed fs/exfat/inode.c:421 [inline]
>  exfat_direct_IO+0x5a3/0x900 fs/exfat/inode.c:485
>  generic_file_direct_write+0x275/0x6a0 mm/filemap.c:3977
>  __generic_file_write_iter+0x242/0x460 mm/filemap.c:4141
>  exfat_file_write_iter+0x894/0xfb0 fs/exfat/file.c:598
>  do_iter_readv_writev+0x88a/0xa30
>  vfs_writev+0x56a/0x14f0 fs/read_write.c:1064
>  do_pwritev fs/read_write.c:1165 [inline]
>  __do_sys_pwritev2 fs/read_write.c:1224 [inline]
>  __se_sys_pwritev2+0x280/0x470 fs/read_write.c:1215
>  __x64_sys_pwritev2+0x11f/0x1a0 fs/read_write.c:1215
>  x64_sys_call+0x2edb/0x3ba0
> arch/x86/include/generated/asm/syscalls_64.h:329
>  do_syscall_x64 arch/x86/entry/common.c:52 [inline]
>  do_syscall_64+0xcd/0x1e0 arch/x86/entry/common.c:83
>  entry_SYSCALL_64_after_hwframe+0x77/0x7f
> 
> Uninit was stored to memory at:
>  memcpy_to_iter lib/iov_iter.c:65 [inline]
>  iterate_bvec include/linux/iov_iter.h:123 [inline]
>  iterate_and_advance2 include/linux/iov_iter.h:304 [inline]
>  iterate_and_advance include/linux/iov_iter.h:328 [inline]
>  _copy_to_iter+0xe53/0x2b30 lib/iov_iter.c:185
>  copy_page_to_iter+0x419/0x880 lib/iov_iter.c:362
>  shmem_file_read_iter+0xa09/0x12b0 mm/shmem.c:3167
>  do_iter_readv_writev+0x88a/0xa30
>  vfs_iter_read+0x278/0x760 fs/read_write.c:923
>  lo_read_simple drivers/block/loop.c:283 [inline]
>  do_req_filebacked drivers/block/loop.c:516 [inline]
>  loop_handle_cmd drivers/block/loop.c:1910 [inline]
>  loop_process_work+0x20fc/0x3750 drivers/block/loop.c:1945
>  loop_rootcg_workfn+0x2b/0x40 drivers/block/loop.c:1976
>  process_one_work kernel/workqueue.c:3229 [inline]
>  process_scheduled_works+0xae0/0x1c40 kernel/workqueue.c:3310
>  worker_thread+0xea7/0x14f0 kernel/workqueue.c:3391
>  kthread+0x3e2/0x540 kernel/kthread.c:389
>  ret_from_fork+0x6d/0x90 arch/x86/kernel/process.c:147
>  ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244
> 
> Uninit was stored to memory at:
>  memcpy_from_iter lib/iov_iter.c:73 [inline]
>  iterate_bvec include/linux/iov_iter.h:123 [inline]
>  iterate_and_advance2 include/linux/iov_iter.h:304 [inline]
>  iterate_and_advance include/linux/iov_iter.h:328 [inline]
>  __copy_from_iter lib/iov_iter.c:249 [inline]
>  copy_page_from_iter_atomic+0x12b7/0x3100 lib/iov_iter.c:481
>  copy_folio_from_iter_atomic include/linux/uio.h:201 [inline]
>  generic_perform_write+0x8d1/0x1080 mm/filemap.c:4066
>  shmem_file_write_iter+0x2ba/0x2f0 mm/shmem.c:3221
>  do_iter_readv_writev+0x88a/0xa30
>  vfs_iter_write+0x44d/0xd40 fs/read_write.c:988
>  lo_write_bvec drivers/block/loop.c:243 [inline]
>  lo_write_simple drivers/block/loop.c:264 [inline]
>  do_req_filebacked drivers/block/loop.c:511 [inline]
>  loop_handle_cmd drivers/block/loop.c:1910 [inline]
>  loop_process_work+0x15e6/0x3750 drivers/block/loop.c:1945
>  loop_rootcg_workfn+0x2b/0x40 drivers/block/loop.c:1976
>  process_one_work kernel/workqueue.c:3229 [inline]
>  process_scheduled_works+0xae0/0x1c40 kernel/workqueue.c:3310
>  worker_thread+0xea7/0x14f0 kernel/workqueue.c:3391
>  kthread+0x3e2/0x540 kernel/kthread.c:389
>  ret_from_fork+0x6d/0x90 arch/x86/kernel/process.c:147
>  ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244
> 
> Uninit was created at:
>  __alloc_pages_noprof+0x9d6/0xe70 mm/page_alloc.c:4756
>  alloc_pages_mpol_noprof+0x299/0x990 mm/mempolicy.c:2265
>  alloc_pages_noprof mm/mempolicy.c:2345 [inline]
>  folio_alloc_noprof+0x1db/0x310 mm/mempolicy.c:2352
>  filemap_alloc_folio_noprof+0xa6/0x440 mm/filemap.c:1010
>  __filemap_get_folio+0xac4/0x1550 mm/filemap.c:1952
>  block_write_begin+0x6e/0x2b0 fs/buffer.c:2226
>  exfat_write_begin+0xfb/0x400 fs/exfat/inode.c:434
>  exfat_extend_valid_size fs/exfat/file.c:553 [inline]
>  exfat_file_write_iter+0x474/0xfb0 fs/exfat/file.c:588
>  do_iter_readv_writev+0x88a/0xa30
>  vfs_writev+0x56a/0x14f0 fs/read_write.c:1064
>  do_pwritev fs/read_write.c:1165 [inline]
>  __do_sys_pwritev2 fs/read_write.c:1224 [inline]
>  __se_sys_pwritev2+0x280/0x470 fs/read_write.c:1215
>  __x64_sys_pwritev2+0x11f/0x1a0 fs/read_write.c:1215
>  x64_sys_call+0x2edb/0x3ba0
> arch/x86/include/generated/asm/syscalls_64.h:329
>  do_syscall_x64 arch/x86/entry/common.c:52 [inline]
>  do_syscall_64+0xcd/0x1e0 arch/x86/entry/common.c:83
>  entry_SYSCALL_64_after_hwframe+0x77/0x7f
> 
> CPU: 0 UID: 0 PID: 5188 Comm: syz-executor221 Not tainted
> 6.12.0-rc1-syzkaller-00031-ge32cde8d2bd7 #0
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
> Google 09/13/2024
> =====================================================
> 
> 
> ---
> This report is generated by a bot. It may contain errors.
> See
> https://urldefense.com/v3/__https://goo.gl/tpsmEJ__;!!JmoZiZGBv3RvKRSx!_E
> FM31JxDI_sBC6NhWwWIWcja8UUVBXZYWyhK0O9vUuSsqy-ZOla4TuepNTA3X-
> btBmzePMIOD0CGeGE0kSF4M2hOwVy57mr50hLBEHu$ for more information
> about syzbot.
> syzbot engineers can be reached at mailto:syzkaller@xxxxxxxxxxxxxxxx.
> 
> syzbot will keep track of this issue. See:
> https://urldefense.com/v3/__https://goo.gl/tpsmEJ*status__;Iw!!JmoZiZGBv3R
> vKRSx!_EFM31JxDI_sBC6NhWwWIWcja8UUVBXZYWyhK0O9vUuSsqy-ZOla4Tu
> epNTA3X-btBmzePMIOD0CGeGE0kSF4M2hOwVy57mr55Eybub8$ 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 syzbot to run the reproducer, reply with:
> #syz test: git://repo/address.git branch-or-commit-hash
> If you attach or paste a git patch, syzbot will apply it before testing.
> 
> 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
From 31f61e9fd68258588910c05dcbd50af381fe8b96 Mon Sep 17 00:00:00 2001
From: Yuezhang Mo <Yuezhang.Mo@xxxxxxxx>
Date: Mon, 14 Oct 2024 12:52:28 +0800
Subject: [PATCH] exfat: do not update ->valid_size in exfat_get_block() if map
 for direct write

Signed-off-by: Yuezhang Mo <Yuezhang.Mo@xxxxxxxx>
---
 fs/exfat/inode.c | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/fs/exfat/inode.c b/fs/exfat/inode.c
index d338a59c27f7..6e1312f30846 100644
--- a/fs/exfat/inode.c
+++ b/fs/exfat/inode.c
@@ -261,8 +261,8 @@ static int exfat_map_cluster(struct inode *inode, unsigned int clu_offset,
 	return 0;
 }
 
-static int exfat_get_block(struct inode *inode, sector_t iblock,
-		struct buffer_head *bh_result, int create)
+static int __exfat_get_block(struct inode *inode, sector_t iblock,
+		struct buffer_head *bh_result, int create, bool dio)
 {
 	struct exfat_inode_info *ei = EXFAT_I(inode);
 	struct super_block *sb = inode->i_sb;
@@ -323,8 +323,10 @@ static int exfat_get_block(struct inode *inode, sector_t iblock,
 		/* The area has not been written, map and mark as new. */
 		set_buffer_new(bh_result);
 
-		ei->valid_size = EXFAT_BLK_TO_B(iblock + max_blocks, sb);
-		mark_inode_dirty(inode);
+		if (!dio) {
+			ei->valid_size = EXFAT_BLK_TO_B(iblock + max_blocks, sb);
+			mark_inode_dirty(inode);
+		}
 	} else {
 		valid_blks = EXFAT_B_TO_BLK(ei->valid_size, sb);
 
@@ -381,6 +383,18 @@ static int exfat_get_block(struct inode *inode, sector_t iblock,
 	return err;
 }
 
+static int exfat_get_block(struct inode *inode, sector_t iblock,
+		struct buffer_head *bh_result, int create)
+{
+	return __exfat_get_block(inode, iblock, bh_result, create, false);
+}
+
+static int exfat_get_block_for_dio(struct inode *inode, sector_t iblock,
+		struct buffer_head *bh_result, int create)
+{
+	return __exfat_get_block(inode, iblock, bh_result, create, true);
+}
+
 static int exfat_read_folio(struct file *file, struct folio *folio)
 {
 	return mpage_read_folio(folio, exfat_get_block);
@@ -479,7 +493,7 @@ static ssize_t exfat_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
 	 * Need to use the DIO_LOCKING for avoiding the race
 	 * condition of exfat_get_block() and ->truncate().
 	 */
-	ret = blockdev_direct_IO(iocb, inode, iter, exfat_get_block);
+	ret = blockdev_direct_IO(iocb, inode, iter, exfat_get_block_for_dio);
 	if (ret < 0) {
 		if (rw == WRITE && ret != -EIOCBQUEUED)
 			exfat_write_failed(mapping, size);
-- 
2.34.1


[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux