[PATCH v2] fs/ntfs: fix BUG_ON of ntfs_read_block()

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

 



From: xu xin <xu.xin16@xxxxxxxxxx>

As the bug description at
https://lore.kernel.org/lkml/20220623033635.973929-1-xu.xin16@xxxxxxxxxx/
attckers can use this bug to crash the system.

So to avoid panic, remove the BUG_ON, and use ntfs_warning to output a
warning to the syslog and return instead until someone really solve
the problem.

Cc: stable@xxxxxxxxxxxxxxx
Reported-by: Zeal Robot <zealci@xxxxxxxxxx>
Reported-by: syzbot+6a5a7672f663cce8b156@xxxxxxxxxxxxxxxxxxxxxxxxx
Reviewed-by: Songyi Zhang <zhang.songyi@xxxxxxxxxx>
Reviewed-by: Yang Yang <yang.yang29@xxxxxxxxxx>
Reviewed-by: Jiang Xuexin<jiang.xuexin@xxxxxxxxxx>
Reviewed-by: Zhang wenya<zhang.wenya1@xxxxxxxxxx>
Signed-off-by: xu xin <xu.xin16@xxxxxxxxxx>
---

Change for v2:
 - Use ntfs_warning instead of WARN().
 - Add the tag Cc: stable@xxxxxxxxxxxxxxx.
---
 fs/ntfs/aops.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/fs/ntfs/aops.c b/fs/ntfs/aops.c
index 5f4fb6ca6f2e..84d68efb4ace 100644
--- a/fs/ntfs/aops.c
+++ b/fs/ntfs/aops.c
@@ -183,7 +183,12 @@ static int ntfs_read_block(struct page *page)
 	vol = ni->vol;
 
 	/* $MFT/$DATA must have its complete runlist in memory at all times. */
-	BUG_ON(!ni->runlist.rl && !ni->mft_no && !NInoAttr(ni));
+	if (unlikely(!ni->runlist.rl && !ni->mft_no && !NInoAttr(ni))) {
+		ntfs_warning(vi->i_sb, "Error because ni->runlist.rl, ni->mft_no, "
+				"and NInoAttr(ni) is null.");
+		unlock_page(page);
+		return -EINVAL;
+	}
 
 	blocksize = vol->sb->s_blocksize;
 	blocksize_bits = vol->sb->s_blocksize_bits;
-- 
2.25.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