aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2019-11-20 11:32:55 -0800
committerTheodore Ts'o <tytso@mit.edu>2019-11-20 22:58:55 -0500
commit3f21d8239567e890b4c41cd69a617ba10cd98f75 (patch)
tree543e68c6904be0c63c4f76bfd1ee4891a7bc6bf0
parent446483e39862d57717fe89190d502bbba0371147 (diff)
downloade2fsprogs-3f21d8239567e890b4c41cd69a617ba10cd98f75.tar.gz
tune2fs: prohibit toggling uninit_bg on live filesystems
An internal customer followed an erroneous AskUbuntu article[1] to try to change the UUID of a live ext4 filesystem. The article claims that you can work around tune2fs' "cannot change UUID on live fs" error by disabling uninit_bg, changing the UUID, and re-enabling the feature. This led to metadata corruption because tune2fs' journal descriptor rewrite races with regular filesystem writes. Therefore, prevent administrators from turning on or off uninit_bg on a mounted fs. [1] https://askubuntu.com/questions/132079/how-do-i-change-uuid-of-a-disk-to-whatever-i-want/195839#459097 Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
-rw-r--r--misc/tune2fs.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/misc/tune2fs.c b/misc/tune2fs.c
index 7d2d38d7d..301cf3880 100644
--- a/misc/tune2fs.c
+++ b/misc/tune2fs.c
@@ -1308,6 +1308,12 @@ mmp_error:
if (FEATURE_ON(E2P_FEATURE_RO_INCOMPAT,
EXT4_FEATURE_RO_COMPAT_GDT_CSUM)) {
+ if (mount_flags & EXT2_MF_MOUNTED) {
+ fputs(_("Cannot enable uninit_bg on a mounted "
+ "filesystem!\n"), stderr);
+ exit(1);
+ }
+
/* Do not enable uninit_bg when metadata_csum enabled */
if (ext2fs_has_feature_metadata_csum(fs->super))
ext2fs_clear_feature_gdt_csum(fs->super);
@@ -1317,6 +1323,12 @@ mmp_error:
if (FEATURE_OFF(E2P_FEATURE_RO_INCOMPAT,
EXT4_FEATURE_RO_COMPAT_GDT_CSUM)) {
+ if (mount_flags & EXT2_MF_MOUNTED) {
+ fputs(_("Cannot disable uninit_bg on a mounted "
+ "filesystem!\n"), stderr);
+ exit(1);
+ }
+
err = disable_uninit_bg(fs,
EXT4_FEATURE_RO_COMPAT_GDT_CSUM);
if (err)