]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commit
reisze2fs: sanity check free block group counts when calculating minimum size
authorTheodore Ts'o <tytso@mit.edu>
Tue, 28 Dec 2021 17:33:15 +0000 (12:33 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 28 Dec 2021 17:33:15 +0000 (12:33 -0500)
commit265f88904e8d47658852e8d41447e727d799cea8
treef36789eb7ac3b89d52a9a9e111cb4502f48b5179
parent45295a35a03ceb759ff9372d49c97d91cbcc7bf7
reisze2fs: sanity check free block group counts when calculating minimum size

If one or more block group descriptor's free blocks count is insane,
it's possible this can lead to a infinite loop in the function
calculate_minimum_resize_size(), which is called by resize2fs -P or
resize2fs -M.

Add some sanity checks to avoid this.  In the case where the file
system is corrupt, this will result in resize2fs -P reporting an
incorrect value, but that's OK, since when we try to do an actual
resize operation, resize2fs requires that the file system be freshly
checked using e2fsck.

https://github.com/tytso/e2fsprogs/issues/94

Fixes: ac94445fc01f ("resize2fs: make minimum size estimates more reliable for mounted fs")
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
resize/resize2fs.c
tests/r_corrupt_fs/expect [new file with mode: 0644]
tests/r_corrupt_fs/name [new file with mode: 0644]
tests/r_corrupt_fs/script [new file with mode: 0644]