|
Kmods SIG |
63c143 |
From 09f7c338da7818fd33af401d855b895550e7c170 Mon Sep 17 00:00:00 2001
|
|
Kmods SIG |
63c143 |
From: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
|
|
Kmods SIG |
63c143 |
Date: Tue, 28 Sep 2021 19:19:17 +0300
|
|
Kmods SIG |
63c143 |
Subject: [Backport 09f7c338da78] src: Reject mount if boot's cluster size
|
|
Kmods SIG |
63c143 |
< media sector size
|
|
Kmods SIG |
63c143 |
|
|
Kmods SIG |
63c143 |
If we continue to work in this case, then we can corrupt fs.
|
|
Kmods SIG |
63c143 |
Fixes: 82cae269cfa9 ("src: Add initialization of super block").
|
|
Kmods SIG |
63c143 |
|
|
Kmods SIG |
63c143 |
Reviewed-by: Kari Argillander <kari.argillander@gmail.com>
|
|
Kmods SIG |
63c143 |
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
|
|
Kmods SIG |
63c143 |
---
|
|
Kmods SIG |
63c143 |
src/super.c | 13 ++++++++++++-
|
|
Kmods SIG |
63c143 |
1 file changed, 12 insertions(+), 1 deletion(-)
|
|
Kmods SIG |
63c143 |
|
|
Kmods SIG |
63c143 |
diff --git a/src/super.c b/src/super.c
|
|
Kmods SIG |
63c143 |
index 800897777eb03855f702e8acf15b39d02c1c2fbf..e9b6a37345769700f682809832d84d8dfc7b9414 100644
|
|
Kmods SIG |
63c143 |
--- a/src/super.c
|
|
Kmods SIG |
63c143 |
+++ b/src/super.c
|
|
Kmods SIG |
63c143 |
@@ -763,9 +763,20 @@ static int ntfs_init_from_boot(struct super_block *sb, u32 sector_size,
|
|
Kmods SIG |
63c143 |
sbi->mft.lbo = mlcn << sbi->cluster_bits;
|
|
Kmods SIG |
63c143 |
sbi->mft.lbo2 = mlcn2 << sbi->cluster_bits;
|
|
Kmods SIG |
63c143 |
|
|
Kmods SIG |
63c143 |
- if (sbi->cluster_size < sbi->sector_size)
|
|
Kmods SIG |
63c143 |
+ /* Compare boot's cluster and sector. */
|
|
Kmods SIG |
63c143 |
+ if (sbi->cluster_size < boot_sector_size)
|
|
Kmods SIG |
63c143 |
goto out;
|
|
Kmods SIG |
63c143 |
|
|
Kmods SIG |
63c143 |
+ /* Compare boot's cluster and media sector. */
|
|
Kmods SIG |
63c143 |
+ if (sbi->cluster_size < sector_size) {
|
|
Kmods SIG |
63c143 |
+ /* No way to use ntfs_get_block in this case. */
|
|
Kmods SIG |
63c143 |
+ ntfs_err(
|
|
Kmods SIG |
63c143 |
+ sb,
|
|
Kmods SIG |
63c143 |
+ "Failed to mount 'cause NTFS's cluster size (%u) is less than media sector size (%u)",
|
|
Kmods SIG |
63c143 |
+ sbi->cluster_size, sector_size);
|
|
Kmods SIG |
63c143 |
+ goto out;
|
|
Kmods SIG |
63c143 |
+ }
|
|
Kmods SIG |
63c143 |
+
|
|
Kmods SIG |
63c143 |
sbi->cluster_mask = sbi->cluster_size - 1;
|
|
Kmods SIG |
63c143 |
sbi->cluster_mask_inv = ~(u64)sbi->cluster_mask;
|
|
Kmods SIG |
63c143 |
sbi->record_size = record_size = boot->record_size < 0
|
|
Kmods SIG |
63c143 |
--
|
|
Kmods SIG |
63c143 |
2.31.1
|
|
Kmods SIG |
63c143 |
|