aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.com>2016-12-20 22:32:19 -0500
committerJ. Bruce Fields <bfields@redhat.com>2017-01-31 12:31:53 -0500
commite35659f1b03c03946cae8abb6b0a9e170b574f1c (patch)
treeba9fb17ace3dc51afa835d969a7bca22be30533c
parent2b477c00f3bd87c3286f5940cb4174d8b01ee0d5 (diff)
NFSD: correctly range-check v4.x minor version when setting versions.
Writing to /proc/fs/nfsd/versions allows individual major versions and NFSv4 minor versions to be enabled or disabled. However NFSv4.0 cannot currently be disabled, thought there is no good reason. Also the minor number is parsed as a 'long' but used as an 'int' so '4294967297' will be incorrectly treated as '1'. This patch removes the test on 'minor == 0' and switches to kstrtouint() to get correct range checking. When reading from /proc/fs/nfsd/versions, 4.0 is current not reported. To allow the disabling for v4.0 to be visible, while maintaining backward compatibility, change code to report "-4.0" if appropriate, but not "+4.0". Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
-rw-r--r--fs/nfsd/nfsctl.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
index f3b2f34b10a3..d54fb0e3f30e 100644
--- a/fs/nfsd/nfsctl.c
+++ b/fs/nfsd/nfsctl.c
@@ -569,8 +569,7 @@ static ssize_t __write_versions(struct file *file, char *buf, size_t size)
569 if (*minorp == '.') { 569 if (*minorp == '.') {
570 if (num != 4) 570 if (num != 4)
571 return -EINVAL; 571 return -EINVAL;
572 minor = simple_strtoul(minorp+1, NULL, 0); 572 if (kstrtouint(minorp+1, 0, &minor) < 0)
573 if (minor == 0)
574 return -EINVAL; 573 return -EINVAL;
575 if (nfsd_minorversion(minor, sign == '-' ? 574 if (nfsd_minorversion(minor, sign == '-' ?
576 NFSD_CLEAR : NFSD_SET) < 0) 575 NFSD_CLEAR : NFSD_SET) < 0)
@@ -613,8 +612,13 @@ static ssize_t __write_versions(struct file *file, char *buf, size_t size)
613 tlen += len; 612 tlen += len;
614 } 613 }
615 if (nfsd_vers(4, NFSD_AVAIL)) 614 if (nfsd_vers(4, NFSD_AVAIL))
616 for (minor = 1; minor <= NFSD_SUPPORTED_MINOR_VERSION; 615 for (minor = 0; minor <= NFSD_SUPPORTED_MINOR_VERSION;
617 minor++) { 616 minor++) {
617 if (minor == 0 && nfsd_minorversion(minor, NFSD_TEST))
618 /* for backward compatibility, don't report
619 * +4.0
620 */
621 continue;
618 len = snprintf(buf, remaining, " %c4.%u", 622 len = snprintf(buf, remaining, " %c4.%u",
619 (nfsd_vers(4, NFSD_TEST) && 623 (nfsd_vers(4, NFSD_TEST) &&
620 nfsd_minorversion(minor, NFSD_TEST)) ? 624 nfsd_minorversion(minor, NFSD_TEST)) ?