From: Azat Khuzhin <a3at.mail@gmail.com>
To: linux-ext4@vger.kernel.org
Cc: lists2009@fnarfbargle.com, tytso@mit.edu,
Azat Khuzhin <a3at.mail@gmail.com>
Subject: [PATCH] resize2fs: fix 32bit overflow during minimal size calculation for 64bit fs.
Date: Sat, 26 Jul 2014 11:19:27 +0400 [thread overview]
Message-ID: <1406359167-13610-1-git-send-email-a3at.mail@gmail.com> (raw)
calculate_minimum_resize_size() multiplying two 32bit numbers, however the
result must be 64bit, but it will be truncated to 32bit, and because of this
data_blocks will be zero, and it will never leave loop:
blocks_per_group=32768 (u32)
extra_groups=131072 (u32)
data_blocks=4294967296 # overflow
And here is messages from log with resize2fs -f 255:
fs has 4007207 inodes, 1957 groups required.
fs requires 4374122900 data blocks.
With 1957 group(s), we have 63820826 blocks available.
Added 131540 extra group(s), blks_needed 4374122900, data_blocks·62023030, last_start 4356599580
Added 131595 extra group(s), blks_needed 4374122900, data_blocks·73483100, last_start 5781212288
Added 131246 extra group(s), blks_needed 4374122900, data_blocks·79184732, last_start 5781244926
Added 131072 extra group(s), blks_needed 4374122900, data_blocks·79184732, last_start 5781277564
Added 131072 extra group(s), blks_needed 4374122900, data_blocks·79184732, last_start 5781310202
...
Reported-by: Brad Campbell <lists2009@fnarfbargle.com>
Tested-by: Brad Campbell <lists2009@fnarfbargle.com>
Signed-off-by: Azat Khuzhin <a3at.mail@gmail.com>
---
resize/resize2fs.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/resize/resize2fs.c b/resize/resize2fs.c
index 546b1d8..6777bfa 100644
--- a/resize/resize2fs.c
+++ b/resize/resize2fs.c
@@ -2479,7 +2479,8 @@ blk64_t calculate_minimum_resize_size(ext2_filsys fs, int flags)
extra_grps = ext2fs_div64_ceil(remainder,
EXT2_BLOCKS_PER_GROUP(fs->super));
- data_blocks += extra_grps * EXT2_BLOCKS_PER_GROUP(fs->super);
+ data_blocks += (unsigned long long)extra_grps *
+ EXT2_BLOCKS_PER_GROUP(fs->super);
/* ok we have to account for the last group */
overhead = calc_group_overhead(fs, groups-1, old_desc_blocks);
--
2.0.1
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next reply other threads:[~2014-07-26 7:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-26 7:19 Azat Khuzhin [this message]
2014-07-26 21:53 ` [PATCH] resize2fs: fix 32bit overflow during minimal size calculation for 64bit fs Theodore Ts'o
2014-07-27 18:21 ` Azat Khuzhin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1406359167-13610-1-git-send-email-a3at.mail@gmail.com \
--to=a3at.mail@gmail.com \
--cc=linux-ext4@vger.kernel.org \
--cc=lists2009@fnarfbargle.com \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).