diff mbox series

[v2] nfs: fix port value parsing

Message ID 165672142729.19075.11075272196311507440.stgit@donald.themaw.net (mailing list archive)
State New
Headers show
Series [v2] nfs: fix port value parsing | expand

Commit Message

Ian Kent July 2, 2022, 12:23 a.m. UTC
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.

Restricting the sloppy option override to handle failure returns for
invalid options only is sufficient to resolve this problem.


v2: utilize the return value from fs_parse() to resolve this problem
    instead of changing the parameter definitions.

Suggested-by: Trond Myklebust <trondmy@hammerspace.com>
Signed-off-by: Ian Kent <raven@themaw.net>
 fs/nfs/fs_context.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series


diff --git a/fs/nfs/fs_context.c b/fs/nfs/fs_context.c
index 9a16897e8dc6..8f1f9b4af89d 100644
--- a/fs/nfs/fs_context.c
+++ b/fs/nfs/fs_context.c
@@ -484,7 +484,7 @@  static int nfs_fs_context_parse_param(struct fs_context *fc,
 	opt = fs_parse(fc, nfs_fs_parameters, param, &result);
 	if (opt < 0)
-		return ctx->sloppy ? 1 : opt;
+		return (opt == -ENOPARAM && ctx->sloppy) ? 1 : opt;
 	if (fc->security)
 		ctx->has_sec_mnt_opts = 1;