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

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