Blame SOURCES/e2fsprogs-1.45.6-resize2fs-avoid-allocating-over-the-MMP-block.patch

f239de
From a7a6126b94b9b6b0f88b5a5cc90d069974c89901 Mon Sep 17 00:00:00 2001
f239de
From: Theodore Ts'o <tytso@mit.edu>
f239de
Date: Sat, 6 Mar 2021 23:08:12 -0500
f239de
Subject: [PATCH 24/46] resize2fs: avoid allocating over the MMP block
f239de
Content-Type: text/plain
f239de
f239de
When resizing past the point where the reserve inode has reserved
f239de
space for the block group descriptors to expand, and resize2fs (in an
f239de
offline resize) needs to move the allocation bitmaps and/or inode
f239de
table around, it's possible for resize2fs to allocate over the MMP
f239de
block, which would be bad.
f239de
f239de
Prevent this from happening by reserving the MMP block as a file
f239de
system metadata block (which it is) in resize2fs's accounting.
f239de
f239de
Addresses-Debian-Bug: #984472
f239de
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
f239de
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
f239de
---
f239de
 resize/resize2fs.c | 5 +++++
f239de
 1 file changed, 5 insertions(+)
f239de
f239de
diff --git a/resize/resize2fs.c b/resize/resize2fs.c
f239de
index 26050fec..e8401e79 100644
f239de
--- a/resize/resize2fs.c
f239de
+++ b/resize/resize2fs.c
f239de
@@ -1176,6 +1176,11 @@ static errcode_t mark_table_blocks(ext2_filsys fs,
f239de
 		if (blk)
f239de
 			ext2fs_mark_block_bitmap2(bmap, blk);
f239de
 	}
f239de
+	/* Reserve the MMP block */
f239de
+	if (ext2fs_has_feature_mmp(fs->super) &&
f239de
+	    fs->super->s_mmp_block > fs->super->s_first_data_block &&
f239de
+	    fs->super->s_mmp_block < ext2fs_blocks_count(fs->super))
f239de
+		ext2fs_mark_block_bitmap2(bmap, fs->super->s_mmp_block);
f239de
 	return 0;
f239de
 }
f239de
 
f239de
-- 
f239de
2.35.1
f239de