All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] fs/ntfs: fix BUG_ON of ntfs_read_block()
@ 2022-07-12  3:05 xu xin
  0 siblings, 0 replies; only message in thread
From: xu xin @ 2022-07-12  3:05 UTC (permalink / raw)
  To: xu.xin16, anton
  Cc: linux-ntfs-dev, linux-kernel, stable, Songyi Zhang, Yang Yang,
	Jiang Xuexin, Zhang wenya, Zeal Robot

As the bug description at
https://lore.kernel.org/lkml/20220623033635.973929-1-xu.xin16@zte.com.cn/
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 ERR.

Cc: stable@vger.kernel.org
Cc: Songyi Zhang <zhang.songyi@zte.com.cn>
Cc: Yang Yang <yang.yang29@zte.com.cn>
Cc: Jiang Xuexin<jiang.xuexin@zte.com.cn>
Cc: Zhang wenya<zhang.wenya1@zte.com.cn>
Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: xu xin <xu.xin16@zte.com.cn>
---

Changelog for v3:
- Use IS_ERR_OR_NULL to check runlist.rl in ntfs_read_block
- Modify ntfs error log.

Changelog for v2:
- Use ntfs_warning instead of WARN().
- Add the tag Cc: stable@vger.kernel.org.

---
 fs/ntfs/aops.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/fs/ntfs/aops.c b/fs/ntfs/aops.c
index 5f4fb6ca6f2e..b9421552686a 100644
--- a/fs/ntfs/aops.c
+++ b/fs/ntfs/aops.c
@@ -183,7 +183,14 @@ 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 (IS_ERR_OR_NULL(ni->runlist.rl) && !ni->mft_no && !NInoAttr(ni)) {
+		ntfs_error(vol->sb, "Runlist of $MFT/$DATA is not cached. "
+				    "$MFT is corrupt.");
+		unlock_page(page);
+		if (IS_ERR(ni->runlist.rl))
+			return PTR_ERR(ni->runlist.rl);
+		return -EFAULT;
+	}
 
 	blocksize = vol->sb->s_blocksize;
 	blocksize_bits = vol->sb->s_blocksize_bits;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-07-12  3:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-12  3:05 [PATCH v3] fs/ntfs: fix BUG_ON of ntfs_read_block() xu xin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.