]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
resize2fs: avoid allocating over the MMP block
authorTheodore Ts'o <tytso@mit.edu>
Sun, 7 Mar 2021 04:08:12 +0000 (23:08 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 7 Mar 2021 04:08:12 +0000 (23:08 -0500)
When resizing past the point where the reserve inode has reserved
space for the block group descriptors to expand, and resize2fs (in an
offline resize) needs to move the allocation bitmaps and/or inode
table around, it's possible for resize2fs to allocate over the MMP
block, which would be bad.

Prevent this from happening by reserving the MMP block as a file
system metadata block (which it is) in resize2fs's accounting.

Addresses-Debian-Bug: #984472
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
resize/resize2fs.c

index a0d08e5b83a4c18c5710459c7b6056ed623848cd..daaa3d491f21e7322fb7d954b7a0112b67366f18 100644 (file)
@@ -1177,6 +1177,11 @@ static errcode_t mark_table_blocks(ext2_filsys fs,
                if (blk)
                        ext2fs_mark_block_bitmap2(bmap, blk);
        }
+       /* Reserve the MMP block */
+       if (ext2fs_has_feature_mmp(fs->super) &&
+           fs->super->s_mmp_block > fs->super->s_first_data_block &&
+           fs->super->s_mmp_block < ext2fs_blocks_count(fs->super))
+               ext2fs_mark_block_bitmap2(bmap, fs->super->s_mmp_block);
        return 0;
 }