[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6036b141-56e2-0d08-b9ff-641c3451f45a@paragon-software.com>
Date: Mon, 27 Sep 2021 18:48:00 +0300
From: Konstantin Komarov <almaz.alexandrovich@...agon-software.com>
To: <ntfs3@...ts.linux.dev>
CC: <linux-kernel@...r.kernel.org>, <linux-fsdevel@...r.kernel.org>
Subject: [PATCH 2/3] fs/ntfs3: Reject mount if boot's cluster size < media
sector size
If we continue to work in this case, then we can corrupt fs.
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@...agon-software.com>
---
fs/ntfs3/super.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c
index 7099d9b1f3aa..193f9a98f6ab 100644
--- a/fs/ntfs3/super.c
+++ b/fs/ntfs3/super.c
@@ -763,9 +763,14 @@ static int ntfs_init_from_boot(struct super_block *sb, u32 sector_size,
sbi->mft.lbo = mlcn << sbi->cluster_bits;
sbi->mft.lbo2 = mlcn2 << sbi->cluster_bits;
+ /* Compare boot's cluster and sector. */
if (sbi->cluster_size < sbi->sector_size)
goto out;
+ /* Compare boot's cluster and media sector. */
+ if (sbi->cluster_size < sector_size)
+ goto out; /* No way to use ntfs_get_block in this case. */
+
sbi->cluster_mask = sbi->cluster_size - 1;
sbi->cluster_mask_inv = ~(u64)sbi->cluster_mask;
sbi->record_size = record_size = boot->record_size < 0
--
2.33.0
Powered by blists - more mailing lists