All of lore.kernel.org
 help / color / mirror / Atom feed
From: "J. Bruce Fields" <bfields@redhat.com>
To: NeilBrown <neilb@suse.com>
Cc: Steve Dickson <SteveD@redhat.com>, linux-nfs@vger.kernel.org
Subject: Re: [PATCH] NFSD: correctly range-check v4.x minor version when setting versions.
Date: Wed, 21 Dec 2016 16:41:53 -0500	[thread overview]
Message-ID: <20161221214153.GK17617@parsley.fieldses.org> (raw)
In-Reply-To: <87bmw6rm7w.fsf@notabene.neil.brown.name>

Makes sense to me, queueing up for 4.11 (none of this seems urgent).

--b.

On Wed, Dec 21, 2016 at 02:32:19PM +1100, NeilBrown wrote:
> 
> 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>
> ---
>  fs/nfsd/nfsctl.c | 10 +++++++---
>  1 file 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)
>  			if (*minorp == '.') {
>  				if (num != 4)
>  					return -EINVAL;
> -				minor = simple_strtoul(minorp+1, NULL, 0);
> -				if (minor == 0)
> +				if (kstrtouint(minorp+1, 0, &minor) < 0)
>  					return -EINVAL;
>  				if (nfsd_minorversion(minor, sign == '-' ?
>  						     NFSD_CLEAR : NFSD_SET) < 0)
> @@ -613,8 +612,13 @@ static ssize_t __write_versions(struct file *file, char *buf, size_t size)
>  			tlen += len;
>  		}
>  	if (nfsd_vers(4, NFSD_AVAIL))
> -		for (minor = 1; minor <= NFSD_SUPPORTED_MINOR_VERSION;
> +		for (minor = 0; minor <= NFSD_SUPPORTED_MINOR_VERSION;
>  		     minor++) {
> +			if (minor == 0 && nfsd_minorversion(minor, NFSD_TEST))
> +				/* for backward compatibility, don't report
> +				 * +4.0
> +				 */
> +				continue;
>  			len = snprintf(buf, remaining, " %c4.%u",
>  					(nfsd_vers(4, NFSD_TEST) &&
>  					 nfsd_minorversion(minor, NFSD_TEST)) ?
> -- 
> 2.11.0
> 



  reply	other threads:[~2016-12-21 21:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-21  3:32 [PATCH] NFSD: correctly range-check v4.x minor version when setting versions NeilBrown
2016-12-21 21:41 ` J. Bruce Fields [this message]
2016-12-21 23:04   ` NeilBrown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161221214153.GK17617@parsley.fieldses.org \
    --to=bfields@redhat.com \
    --cc=SteveD@redhat.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=neilb@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.