linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: tytso@mit.edu, darrick.wong@oracle.com
Cc: linux-ext4@vger.kernel.org
Subject: [PATCH 3/8] ext2: only permit ro mounts with compat features we know we don't support
Date: Mon, 12 Oct 2015 14:54:37 -0700	[thread overview]
Message-ID: <20151012215437.28872.14707.stgit@birch.djwong.org> (raw)
In-Reply-To: <20151012215416.28872.8160.stgit@birch.djwong.org>

The ext2 mount code never checks the compat features against the ones
it knows about.  This is correct behavior since compat features are
supposed to be rw-compatible with old drivers; however, for certain
configurations (journalled rootfs) the admin is unlikely to want
no-journal mode.  Since we changed the default probe order to put ext4
first, we can make ext2.ko only allow readonly mounts if has_journal is
found.

(Remember, this only affects mounting ext3 filesystems on ext2.ko.)

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 fs/ext2/ext2.h  |    6 +++++-
 fs/ext2/super.c |   19 +++++++++++++++++++
 2 files changed, 24 insertions(+), 1 deletion(-)


diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h
index 8d15feb..ce508b1 100644
--- a/fs/ext2/ext2.h
+++ b/fs/ext2/ext2.h
@@ -547,7 +547,11 @@ struct ext2_super_block {
 #define EXT2_FEATURE_INCOMPAT_META_BG		0x0010
 #define EXT2_FEATURE_INCOMPAT_ANY		0xffffffff
 
-#define EXT2_FEATURE_COMPAT_SUPP	EXT2_FEATURE_COMPAT_EXT_ATTR
+#define EXT2_FEATURE_COMPAT_SUPP	(EXT2_FEATURE_COMPAT_DIR_PREALLOC| \
+					 EXT2_FEATURE_COMPAT_IMAGIC_INODES| \
+					 EXT2_FEATURE_COMPAT_EXT_ATTR| \
+					 EXT2_FEATURE_COMPAT_RESIZE_INO| \
+					 EXT2_FEATURE_COMPAT_DIR_INDEX)
 #define EXT2_FEATURE_INCOMPAT_SUPP	(EXT2_FEATURE_INCOMPAT_FILETYPE| \
 					 EXT2_FEATURE_INCOMPAT_META_BG)
 #define EXT2_FEATURE_RO_COMPAT_SUPP	(EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \
diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index 900e19c..40c312f 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -896,6 +896,14 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
 	 * previously didn't change the revision level when setting the flags,
 	 * so there is a chance incompat flags are set on a rev 0 filesystem.
 	 */
+#ifdef CONFIG_EXT4_FS
+	/* Journalled FS should mount with ext4 if it's available */
+	if (EXT2_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_HAS_JOURNAL)) {
+		ext2_msg(sb, KERN_ERR,	"warning: journal detected; cowardly "
+			"refusing to mount read-write.  Try ext4.");
+		sb->s_flags |= MS_RDONLY;
+	}
+#endif
 	features = EXT2_HAS_INCOMPAT_FEATURE(sb, ~EXT2_FEATURE_INCOMPAT_SUPP);
 	if (features) {
 		ext2_msg(sb, KERN_ERR,	"error: couldn't mount because of "
@@ -1336,6 +1344,17 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
 			err = -EROFS;
 			goto restore_opts;
 		}
+#ifdef CONFIG_EXT4_FS
+		/* Journalled FS should mount with ext4 if it's available */
+		if (EXT2_HAS_COMPAT_FEATURE(sb,
+					    EXT3_FEATURE_COMPAT_HAS_JOURNAL)) {
+			ext2_msg(sb, KERN_ERR,	"warning: journal detected; "
+				"cowardly refusing to remount read-write.  "
+				"Try ext4.");
+			err = -EROFS;
+			goto restore_opts;
+		}
+#endif
 		/*
 		 * Mounting a RDONLY partition read-write, so reread and
 		 * store the current valid flag.  (It may have been changed


  parent reply	other threads:[~2015-10-12 21:54 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-12 21:54 [PATCH 0/8] ext4/jbd2: misc fixes and cleanups; save checksum seeds Darrick J. Wong
2015-10-12 21:54 ` [PATCH 1/8] jbd2: gate checksum calculations on crc driver presence, not sb flags Darrick J. Wong
2015-10-15 14:32   ` Theodore Ts'o
2015-10-12 21:54 ` [PATCH 2/8] ext4: promote ext4 over ext2 in the default probe order Darrick J. Wong
2015-10-15 14:34   ` Theodore Ts'o
2015-10-12 21:54 ` Darrick J. Wong [this message]
2015-10-15 14:37   ` [PATCH 3/8] ext2: only permit ro mounts with compat features we know we don't support Theodore Ts'o
2015-10-15 16:47     ` Darrick J. Wong
2015-10-12 21:54 ` [PATCH 4/8] ext4: store checksum seed in superblock Darrick J. Wong
2015-10-15 14:45   ` Theodore Ts'o
2015-10-18  1:19   ` Theodore Ts'o
2015-10-18  1:23     ` Darrick J. Wong
2015-10-18  2:14       ` Theodore Ts'o
2015-10-12 21:54 ` [PATCH 5/8] ext4: call out CRC and corruption errors with specific error codes Darrick J. Wong
2015-10-15 14:47   ` Theodore Ts'o
2015-10-12 21:54 ` [PATCH 6/8] ext4: make the bitmap read routines return real " Darrick J. Wong
2015-10-15 14:57   ` Theodore Ts'o
2015-10-15 15:02     ` Darrick J. Wong
2015-10-15 16:36   ` [PATCH v2 " Darrick J. Wong
2015-10-18  1:45     ` Theodore Ts'o
2015-10-12 21:55 ` [PATCH 7/8] ext4: clean up feature test macros with predicate functions Darrick J. Wong
2015-10-15 15:12   ` Theodore Ts'o
2015-10-12 21:55 ` [PATCH 8/8] jbd2: " Darrick J. Wong
2015-10-15 15:12   ` Theodore 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=20151012215437.28872.14707.stgit@birch.djwong.org \
    --to=darrick.wong@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).