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 ERR. Cc: stable@xxxxxxxxxxxxxxx Cc: Songyi Zhang <zhang.songyi@xxxxxxxxxx> Cc: Yang Yang <yang.yang29@xxxxxxxxxx> Cc: Jiang Xuexin<jiang.xuexin@xxxxxxxxxx> Cc: Zhang wenya<zhang.wenya1@xxxxxxxxxx> Reported-by: Zeal Robot <zealci@xxxxxxxxxx> Signed-off-by: xu xin <xu.xin16@xxxxxxxxxx> --- 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@xxxxxxxxxxxxxxx. --- 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