Blame SOURCES/e2fsprogs-1.45.5-tune2fs-prohibit-toggling-uninit_bg-on-live-filesyst.patch

a9c310
From d758a667f27b38d9ecc0715062307a8bce741aee Mon Sep 17 00:00:00 2001
a9c310
From: "Darrick J. Wong" <darrick.wong@oracle.com>
a9c310
Date: Wed, 20 Nov 2019 11:32:55 -0800
a9c310
Subject: [PATCH 06/10] tune2fs: prohibit toggling uninit_bg on live
a9c310
 filesystems
a9c310
a9c310
An internal customer followed an erroneous AskUbuntu article[1] to try to
a9c310
change the UUID of a live ext4 filesystem.  The article claims that you
a9c310
can work around tune2fs' "cannot change UUID on live fs" error by
a9c310
disabling uninit_bg, changing the UUID, and re-enabling the feature.
a9c310
a9c310
This led to metadata corruption because tune2fs' journal descriptor
a9c310
rewrite races with regular filesystem writes.  Therefore, prevent
a9c310
administrators from turning on or off uninit_bg on a mounted fs.
a9c310
a9c310
[1] https://askubuntu.com/questions/132079/how-do-i-change-uuid-of-a-disk-to-whatever-i-want/195839#459097
a9c310
a9c310
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
a9c310
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
a9c310
---
a9c310
 misc/tune2fs.c | 12 ++++++++++++
a9c310
 1 file changed, 12 insertions(+)
a9c310
a9c310
diff --git a/misc/tune2fs.c b/misc/tune2fs.c
a9c310
index 7d2d38d7..301cf388 100644
a9c310
--- a/misc/tune2fs.c
a9c310
+++ b/misc/tune2fs.c
a9c310
@@ -1308,6 +1308,12 @@ mmp_error:
a9c310
 
a9c310
 	if (FEATURE_ON(E2P_FEATURE_RO_INCOMPAT,
a9c310
 		       EXT4_FEATURE_RO_COMPAT_GDT_CSUM)) {
a9c310
+		if (mount_flags & EXT2_MF_MOUNTED) {
a9c310
+			fputs(_("Cannot enable uninit_bg on a mounted "
a9c310
+				"filesystem!\n"), stderr);
a9c310
+			exit(1);
a9c310
+		}
a9c310
+
a9c310
 		/* Do not enable uninit_bg when metadata_csum enabled */
a9c310
 		if (ext2fs_has_feature_metadata_csum(fs->super))
a9c310
 			ext2fs_clear_feature_gdt_csum(fs->super);
a9c310
@@ -1317,6 +1323,12 @@ mmp_error:
a9c310
 
a9c310
 	if (FEATURE_OFF(E2P_FEATURE_RO_INCOMPAT,
a9c310
 			EXT4_FEATURE_RO_COMPAT_GDT_CSUM)) {
a9c310
+		if (mount_flags & EXT2_MF_MOUNTED) {
a9c310
+			fputs(_("Cannot disable uninit_bg on a mounted "
a9c310
+				"filesystem!\n"), stderr);
a9c310
+			exit(1);
a9c310
+		}
a9c310
+
a9c310
 		err = disable_uninit_bg(fs,
a9c310
 				EXT4_FEATURE_RO_COMPAT_GDT_CSUM);
a9c310
 		if (err)
a9c310
-- 
a9c310
2.21.1
a9c310