NFS guard against incorrect vers inputs from nfs-utils
Subsystems (2)
PATCH 1/1 NFS guard against incorrect vers inputs from nfs-utils
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.
--- fs/nfs/super.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
fs/nfs/super.c +9 -1
@@ -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 ; }/*
Signature · 1 line
1.8.3.1
Hey Olga,
Quoted 4 lines · Olga Kornievskaia
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.
I'm thinking this is probably more of mount problem...
mount -t nfs4 -o minorversion=0 server:/export /mnt
shouldn't this be a v4.0 mount instead of a 4.2 mount?
steved.
Quoted 49 lines
Signed-off-by Olga Kornievskaia <[email protected]>--- fs/nfs/super.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)fs/nfs/super.c +9
-1@@ -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 ; }/*
Quoted 8 lines · Steve Dickson
Hey Olga,
Quoted 4 lines · Olga Kornievskaia
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.
I'm thinking this is probably more of mount problem...
Yes the problem is a broken user land sending incorrect arguments but I still think the kernel needs to do sanity checking on arguments to prevent this from happening again.
Quoted 3 lines
mount -t nfs4 -o minorversion=0 server:/export /mnt
shouldn't this be a v4.0 mount instead of a 4.2 mount?
Yes I would think this should create a v4.0 mount.
Quoted 56 lines
steved.
Quoted 39 lines
Signed-off-by Olga Kornievskaia <[email protected]>--- fs/nfs/super.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)fs/nfs/super.c +5
-1@@ -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:fs/nfs/super.c static int nfs_parse_mount_options(char *raw, · line 1698
Quoted 10 lines
fs/nfs/super.c +4
-0@@ -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 ; }/* --
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 14 lines · Olga Kornievskaia
Quoted 8 lines · Steve Dickson
Hey Olga,
Quoted 4 lines · Olga Kornievskaia
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.
I'm thinking this is probably more of mount problem...
Yes the problem is a broken user land sending incorrect arguments but I still think the kernel needs to do sanity checking on arguments to prevent this from happening again.
Quoted 5 lines
Quoted 3 lines
mount -t nfs4 -o minorversion=0 server:/export /mnt
shouldn't this be a v4.0 mount instead of a 4.2 mount?
Yes I would think this should create a v4.0 mount.
Way back when... there was some talk about deprecating minorversion= flag... Since it is broken, maybe this is a good time to do it?
Thoughts?
steved.
T24gRnJpLCAyMDE4LTAyLTIzIGF0IDEzOjQ1IC0wNTAwLCBTdGV2ZS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oted 21 lines · Olga Kornievskaia
Quoted 11 lines · Steve Dickson
Hey Olga,
Quoted 7 lines · Olga Kornievskaia
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.Quoted 1 line
I'm thinking this is probably more of mount problem...
Yes the problem is a broken user land sending incorrect arguments but
I still think the kernel needs to do sanity checking on arguments to
prevent this from happening again.Quoted 5 lines
Quoted 3 lines
mount -t nfs4 -o minorversion=0 server:/export /mnt
shouldn't this be a v4.0 mount instead of a 4.2 mount?
Yes I would think this should create a v4.0 mount.
Way back when... there was some talk about deprecating minorversion= flag... Since it is broken, maybe this is a good time to do it?
Quoted 6 lines
Quoted 1 line
Thoughts?
I've never liked the separate v4-only 'minorversion' keyword, which is why I introduced the 'version=4.x' format. My preference is therefore that we continue to deprecate use of 'minorversion' with a view to killing it off completely.
It all seems like a good idea except I wonder how widely used and relied on "minorversion" option is. Steve you might have a good idea about it.
Quoted 5 lines
--
Trond Myklebust
Linux NFS client maintainer, PrimaryData
[email protected]
Quoted 38 lines · Olga Kornievskaia
Quoted 36 lines · Trond Myklebust
Quoted 34 lines · Steve Dickson
Quoted 21 lines · Olga Kornievskaia
Quoted 11 lines · Steve Dickson
Hey Olga,
Quoted 7 lines · Olga Kornievskaia
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.Quoted 1 line
I'm thinking this is probably more of mount problem...
Yes the problem is a broken user land sending incorrect arguments but
I still think the kernel needs to do sanity checking on arguments to
prevent this from happening again.Quoted 5 lines
Quoted 3 lines
mount -t nfs4 -o minorversion=0 server:/export /mnt
shouldn't this be a v4.0 mount instead of a 4.2 mount?
Yes I would think this should create a v4.0 mount.
Way back when... there was some talk about deprecating minorversion= flag... Since it is broken, maybe this is a good time to do it?
Thoughts?
Quoted 8 lines
Quoted 4 lines
I've never liked the separate v4-only 'minorversion' keyword, which is why I introduced the 'version=4.x' format. My preference is therefore that we continue to deprecate use of 'minorversion' with a view to killing it off completely.
It all seems like a good idea except I wonder how widely used and relied on "minorversion" option is. Steve you might have a good idea about it.
I have no idea... Actually I'm not sure how to deprecate a mount option... I don't think that has every happen before... But I'm sure it will break something! ;-)
steved.
Quoted 6 lines
Quoted 6 lines
--
Trond Myklebust
Linux NFS client maintainer, PrimaryData
[email protected]