linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] NFS guard against incorrect vers inputs from nfs-utils
@ 2018-02-22 19:28 Olga Kornievskaia
  2018-02-23 16:24 ` Steve Dickson
  0 siblings, 1 reply; 7+ messages in thread
From: Olga Kornievskaia @ 2018-02-22 19:28 UTC (permalink / raw)
  To: Trond.Myklebust, anna.schumaker; +Cc: linux-nfs

It is possible that userland can pass to the kernel mismatching
inputs for the minorversion. like vers=4.1,minorversion=0. Instead
of making the kernel responposible for 'choosing' the minorversion,
make the userland always responsible for not sending a mismatch.

Signed-off-by: Olga Kornievskaia <kolga@netapp.com>
---
 fs/nfs/super.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 29bacdc..90c0584 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -1207,7 +1207,7 @@ static int nfs_parse_mount_options(char *raw,
 				   struct nfs_parsed_mount_data *mnt)
 {
 	char *p, *string, *secdata;
-	int rc, sloppy = 0, invalid_option = 0;
+	int rc, sloppy = 0, invalid_option = 0, minorversion = -1;
 	unsigned short protofamily = AF_UNSPEC;
 	unsigned short mountfamily = AF_UNSPEC;
 
@@ -1419,6 +1419,7 @@ static int nfs_parse_mount_options(char *raw,
 			if (option > NFS4_MAX_MINOR_VERSION)
 				goto out_invalid_value;
 			mnt->minorversion = option;
+			minorversion = option;
 			break;
 
 		/*
@@ -1655,6 +1656,9 @@ static int nfs_parse_mount_options(char *raw,
 		}
 	}
 
+	if (minorversion >= 0 && minorversion != mnt->minorversion)
+		goto out_mountvers_mismatch;
+
 	return 1;
 
 out_mountproto_mismatch:
@@ -1685,6 +1689,10 @@ static int nfs_parse_mount_options(char *raw,
 	free_secdata(secdata);
 	printk(KERN_INFO "NFS: security options invalid: %d\n", rc);
 	return 0;
+out_mountvers_mismatch:
+	printk(KERN_INFO "NFS: mismatch versions supplied vers=4.%d and "
+			 "minorversion=%d\n", mnt->minorversion, minorversion);
+	return 0;
 }
 
 /*
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-02-26 14:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-22 19:28 [PATCH 1/1] NFS guard against incorrect vers inputs from nfs-utils Olga Kornievskaia
2018-02-23 16:24 ` Steve Dickson
2018-02-23 17:05   ` Olga Kornievskaia
2018-02-23 18:45     ` Steve Dickson
2018-02-23 19:09       ` Trond Myklebust
2018-02-23 19:28         ` Olga Kornievskaia
2018-02-26 14:07           ` Steve Dickson

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).