From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: "Theodore Ts'o" <tytso@mit.edu>
Cc: linux-ext4 <linux-ext4@vger.kernel.org>, eric.saint.etienne@oracle.com
Subject: [PATCH] tune2fs: prohibit toggling uninit_bg on live filesystems
Date: Wed, 20 Nov 2019 11:32:55 -0800 [thread overview]
Message-ID: <20191120193255.GF6213@magnolia> (raw)
From: Darrick J. Wong <darrick.wong@oracle.com>
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>
---
misc/tune2fs.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/misc/tune2fs.c b/misc/tune2fs.c
index 8368a733..150dc916 100644
--- a/misc/tune2fs.c
+++ b/misc/tune2fs.c
@@ -1312,6 +1312,12 @@ static int update_feature_set(ext2_filsys fs, char *features)
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);
@@ -1321,6 +1327,12 @@ static int update_feature_set(ext2_filsys fs, char *features)
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)
next reply other threads:[~2019-11-20 19:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-20 19:32 Darrick J. Wong [this message]
2019-11-21 18:22 ` [PATCH] tune2fs: prohibit toggling uninit_bg on live filesystems Theodore Y. Ts'o
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191120193255.GF6213@magnolia \
--to=darrick.wong@oracle.com \
--cc=eric.saint.etienne@oracle.com \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).