Blob Blame History Raw
From: Jan Kara <jack@suse.cz>
Subject: ext4: add allow_unsupported module parameter
Patch-mainline: never, SUSE-specific
References: fate#317919, SLE-8615, bsc#1149651, SLE-9243

Disallow access to filesystem with unsupported features by default but
leave a chance to access the filesystem via module parameter override
(taints kernel).

The status can be toggled during runtime by changing the exported module
parameter in /sys.

Currently we make bigalloc feature supported only in read-only mode as it is
not completely mature yet.

Signed-off-by: Jan Kara <jack@suse.cz>

---
 fs/ext4/ext4.h  |    3 +++
 fs/ext4/super.c |   23 +++++++++++++++++++++++
 2 files changed, 26 insertions(+)

--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -43,6 +43,8 @@
 #ifdef __KERNEL__
 #include <linux/compat.h>
 #endif
+#include <linux/module.h>
+#include <linux/unsupported-feature.h>
 
 /*
  * The fourth extended filesystem constants/structures
@@ -3249,4 +3251,5 @@ extern const struct iomap_ops ext4_iomap
 #define EFSBADCRC	EBADMSG		/* Bad CRC detected */
 #define EFSCORRUPTED	EUCLEAN		/* Filesystem is corrupted */
 
+DECLARE_SUSE_UNSUPPORTED_FEATURE(ext4);
 #endif	/* _EXT4_H */
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -53,6 +53,8 @@
 #include "mballoc.h"
 #include "fsmap.h"
 
+DEFINE_SUSE_UNSUPPORTED_FEATURE(ext4)
+
 #define CREATE_TRACE_POINTS
 #include <trace/events/ext4.h>
 
@@ -2773,6 +2775,21 @@ static unsigned long ext4_get_stripe_siz
 	return ret;
 }
 
+static int
+ext4_check_unsupported_ro(struct super_block *sb, bool allow_ro, bool readonly,
+			  const char *description)
+{
+       if (allow_ro && readonly)
+               return 0;
+
+       if (ext4_allow_unsupported())
+               return 0;
+
+       ext4_msg(sb, KERN_ERR, "Couldn't mount %sbecause of SUSE-unsupported optional feature %s.  Load module with allow_unsupported=1.",
+                 allow_ro ? "RDWR " : "", description);
+       return -EINVAL;
+}
+
 /*
  * Check whether this filesystem can be mounted based on
  * the features present and the RDONLY/RDWR mount requested.
@@ -2807,6 +2824,12 @@ static int ext4_feature_set_ok(struct su
 				~EXT4_FEATURE_RO_COMPAT_SUPP));
 		return 0;
 	}
+
+
+	if (ext4_has_feature_bigalloc(sb) &&
+	    ext4_check_unsupported_ro(sb, true, readonly, "BIGALLOC"))
+		return 0;
+
 	/*
 	 * Large file size enabled file system can only be mounted
 	 * read-write on 32-bit systems if kernel is built with CONFIG_LBDAF