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

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