Blob Blame History Raw
From: NeilBrown <neilb@suse.com>
Subject: NFS add module option to limit NFSv4 minor version.
Patch-mainline: Never, suse-specific
References: jsc#PM-231

We want to provide NFSv4.2 client support as opt-in.
Default mount.nfs behaviour is to mount highest version supported.
So add a module option to set highest supported option, and
reject mount attempt for higher minor.
Set default to '1' for SLE12 and SLE15.0
Set default to '2' for SLE15-SP1 and later.

Signed-off-by: NeilBrown <neilb@suse.com>

---
 fs/nfs/super.c |   11 +++++++++++
 1 file changed, 11 insertions(+)

--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -76,6 +76,12 @@
 #define NFS_DEFAULT_VERSION 2
 #endif
 
+#if CONFIG_SUSE_VERSION < 15 || (CONFIG_SUSE_VERSION == 15 && CONFIG_SUSE_PATCHLEVEL == 0)
+static int max_minor_version = 1;
+#else
+static int max_minor_version = 2;
+#endif
+
 #define NFS_MAX_CONNECTIONS 16
 
 enum {
@@ -1425,6 +1431,8 @@ static int nfs_parse_mount_options(char
 				goto out_invalid_value;
 			if (option > NFS4_MAX_MINOR_VERSION)
 				goto out_invalid_value;
+			if (option > max_minor_version)
+				goto out_invalid_value;
 			mnt->minorversion = option;
 			break;
 
@@ -2923,5 +2931,8 @@ MODULE_PARM_DESC(recover_lost_locks,
 		 "If the server reports that a lock might be lost, "
 		 "try to recover it risking data corruption.");
 
+module_param(max_minor_version, int, 0644);
+MODULE_PARM_DESC(max_minor_version,
+		 "Maximum NFSv4.x minor version that can be mounted");
 
 #endif /* CONFIG_NFS_V4 */