All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ian Kent <raven@themaw.net>
To: Trond Myklebust <trond.myklebust@hammerspace.com>,
	Anna Schumaker <Anna.Schumaker@Netapp.com>
Cc: linux-nfs-list <linux-nfs@vger.kernel.org>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>,
	David Howells <dhowells@redhat.com>,
	Steve Dickson <SteveD@redhat.com>,
	Benjamin Coddington <bcodding@redhat.com>
Subject: [REPOST PATCH] nfs: fix port value parsing
Date: Tue, 28 Jun 2022 08:25:07 +0800	[thread overview]
Message-ID: <165637590710.37553.7481596265813355098.stgit@donald.themaw.net> (raw)

The valid values of nfs options port and mountport are 0 to USHRT_MAX.

The fs parser will return a fail for port values that are negative
and the sloppy option handling then returns success.

But the sloppy option handling is meant to return success for invalid
options not valid options with invalid values.

Parsing these values as s32 rather than u32 prevents the parser from
returning a parse fail allowing the later USHRT_MAX option check to
correctly return a fail in this case. The result check could be changed
to use the int_32 union variant as well but leaving it as a uint_32
check avoids using two logical compares instead of one.

Signed-off-by: Ian Kent <raven@themaw.net>
---
 fs/nfs/fs_context.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/nfs/fs_context.c b/fs/nfs/fs_context.c
index 9a16897e8dc6..f4da1d2be616 100644
--- a/fs/nfs/fs_context.c
+++ b/fs/nfs/fs_context.c
@@ -156,14 +156,14 @@ static const struct fs_parameter_spec nfs_fs_parameters[] = {
 	fsparam_u32   ("minorversion",	Opt_minorversion),
 	fsparam_string("mountaddr",	Opt_mountaddr),
 	fsparam_string("mounthost",	Opt_mounthost),
-	fsparam_u32   ("mountport",	Opt_mountport),
+	fsparam_s32   ("mountport",	Opt_mountport),
 	fsparam_string("mountproto",	Opt_mountproto),
 	fsparam_u32   ("mountvers",	Opt_mountvers),
 	fsparam_u32   ("namlen",	Opt_namelen),
 	fsparam_u32   ("nconnect",	Opt_nconnect),
 	fsparam_u32   ("max_connect",	Opt_max_connect),
 	fsparam_string("nfsvers",	Opt_vers),
-	fsparam_u32   ("port",		Opt_port),
+	fsparam_s32   ("port",		Opt_port),
 	fsparam_flag_no("posix",	Opt_posix),
 	fsparam_string("proto",		Opt_proto),
 	fsparam_flag_no("rdirplus",	Opt_rdirplus),



             reply	other threads:[~2022-06-28  0:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-28  0:25 Ian Kent [this message]
2022-06-28 14:34 ` [REPOST PATCH] nfs: fix port value parsing Trond Myklebust
2022-06-29  1:02   ` Ian Kent
2022-06-29 15:33     ` Trond Myklebust
2022-06-29 23:33       ` Ian Kent
2022-06-29 23:57         ` Trond Myklebust
2022-06-30  0:41           ` Ian Kent
2022-06-30  0:46             ` Ian Kent
2022-07-01  6:10           ` Ian Kent
2022-07-01 14:25             ` Trond Myklebust

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=165637590710.37553.7481596265813355098.stgit@donald.themaw.net \
    --to=raven@themaw.net \
    --cc=Anna.Schumaker@Netapp.com \
    --cc=SteveD@redhat.com \
    --cc=bcodding@redhat.com \
    --cc=dhowells@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=trond.myklebust@hammerspace.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.