* [PATCH] mke2fs: fix check for absurdly large devices
@ 2019-04-25 21:24 Andreas Dilger
2019-05-05 22:34 ` Theodore Ts'o
0 siblings, 1 reply; 2+ messages in thread
From: Andreas Dilger @ 2019-04-25 21:24 UTC (permalink / raw)
To: tytso; +Cc: linux-ext4, Andreas Dilger
The check in mke2fs is intended to be for the number of blocks in the
filesystem exceeding the maximum number of addressable blocks in 2^32
bitmaps, which is (2^32 * 8 bits/byte * blocksize) = 2^47 blocks,
or 2^59 bytes = 512PiB for the common 4KiB blocksize.
However, s_log_blocksize holds log2(blocksize_in_kb), so the current
calculation is a factor of 2^10 too small. This caused mke2fs to fail
while trying to format a 900TB filesystem.
Fixes: 101ef2e93c25 ("mke2fs: Avoid crashes / infinite loops for absurdly large devices")
Signed-off-by: Andreas Dilger <adilger@dilger.ca>
---
misc/mke2fs.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index be3586c..23e313c 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -2190,9 +2190,11 @@ profile_error:
}
/*
* Guard against group descriptor count overflowing... Mostly to avoid
- * strange results for absurdly large devices.
+ * strange results for absurdly large devices. This is in log2:
+ * (blocksize) * (bits per byte) * (maximum number of block groups)
*/
- if (fs_blocks_count > ((1ULL << (fs_param.s_log_block_size + 3 + 32)) - 1)) {
+ if (fs_blocks_count >
+ (1ULL << (EXT2_BLOCK_SIZE_BITS(&fs_param) + 3 + 32)) - 1) {
fprintf(stderr, _("%s: Size of device (0x%llx blocks) %s "
"too big to create\n\t"
"a filesystem using a blocksize of %d.\n"),
--
1.8.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mke2fs: fix check for absurdly large devices
2019-04-25 21:24 [PATCH] mke2fs: fix check for absurdly large devices Andreas Dilger
@ 2019-05-05 22:34 ` Theodore Ts'o
0 siblings, 0 replies; 2+ messages in thread
From: Theodore Ts'o @ 2019-05-05 22:34 UTC (permalink / raw)
To: Andreas Dilger; +Cc: linux-ext4
On Thu, Apr 25, 2019 at 11:24:30PM +0200, Andreas Dilger wrote:
> The check in mke2fs is intended to be for the number of blocks in the
> filesystem exceeding the maximum number of addressable blocks in 2^32
> bitmaps, which is (2^32 * 8 bits/byte * blocksize) = 2^47 blocks,
> or 2^59 bytes = 512PiB for the common 4KiB blocksize.
>
> However, s_log_blocksize holds log2(blocksize_in_kb), so the current
> calculation is a factor of 2^10 too small. This caused mke2fs to fail
> while trying to format a 900TB filesystem.
>
> Fixes: 101ef2e93c25 ("mke2fs: Avoid crashes / infinite loops for absurdly large devices")
> Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Thanks, applied.
- Ted
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-05-05 22:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-25 21:24 [PATCH] mke2fs: fix check for absurdly large devices Andreas Dilger
2019-05-05 22:34 ` Theodore Ts'o
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.