From: Ian Kent Date: Sat, 2 Jul 2022 00:23:47 +0000 (+0800) Subject: nfs: fix port value parsing X-Git-Tag: v6.1-rc5~442^2~46 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8b4e87a1d68f5ae440c42c15c238fd964fd381d0;p=platform%2Fkernel%2Flinux-starfive.git nfs: fix port value parsing 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. Changes: v2: utilize the return value from fs_parse() to resolve this problem instead of changing the parameter definitions. Suggested-by: Trond Myklebust Signed-off-by: Ian Kent Signed-off-by: Trond Myklebust --- diff --git a/fs/nfs/fs_context.c b/fs/nfs/fs_context.c index 9a16897..8f1f9b4 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;