Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp48692iog; Wed, 29 Jun 2022 17:49:18 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vr/IAtTb9+SCGN+Y9gsJWI00cUKZ40WYY/I6QKaak5XQsHcpZQvJfbx3+qbRcF1Y8MjEZQ X-Received: by 2002:a05:6a00:2493:b0:525:a822:d736 with SMTP id c19-20020a056a00249300b00525a822d736mr12804028pfv.51.1656550158248; Wed, 29 Jun 2022 17:49:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656550158; cv=none; d=google.com; s=arc-20160816; b=G9YV9FJh8zzKDwfrKr6naQ5qHgAYahdHrKi+j6lOXpGYQUWKz1S3SITqp+Nlv53h2g BVs+GiPT5CCxfRZt3DH4sLLKF34Tzzh7N6d6jT5Ptxjzh1e5W/wRupmgLE/k5HC+iX+T OfoYVpf/9dZ2BEJjGgBl6UNXoYU4n1KKfGM1/vBr3M4Aq5gjhImhW6su7PZhuu+YuvVE V5OIjrrmBMhTPretd2f1KnhThmRLX8D2BYnAq6hUyhfPHVAgJZjvv1vDNJLo6EIl7E5b Ec0tPB8g0W+kr9AwhLbbALHd9t3BuVk6d6jTvcdZbi/72Vh5lDPpx544wmuhl2OWS4KV It2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:feedback-id:dkim-signature:dkim-signature; bh=YGkknG7f4f40yQzuN+h1Ss3pBCm01aDX5rQ1G2imCNI=; b=gFuLjMA9zyBrxRKlhYxv6/LUkFQuwz2yWwJ2vOVQsYBrvc4al9vz1NGoaFJy3kEwAG 8DMBk7YbYCqE6pCV/4+kiVPv8Zto3vLGY/WzBncJWNDJwi6/doIQXJRcWG3J4OM0iN2u dl7fLlhHjsmGTRDj07L8ZCjfuAnjkz06PSnquHhbbKwY/YH8Sihx9ryzpq2F1Io4c/sG 483r2VLXqhk1CBxx4QEP590qLZmzlSjDBvliaQ3uqCC58Euc5mLo93l1N17Z5l7kw3RJ 4jRMAf0JFSN9+ZEmusQqazJ5Xhy7m0WgwSXh4MkZdMvlAV7KxfGuJZbUX3DYSCCeYeCH MBoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@themaw.net header.s=fm1 header.b=XYOvYhtl; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=NVOLqdKy; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o20-20020a635d54000000b003db48a0c6ecsi24414713pgm.792.2022.06.29.17.48.59; Wed, 29 Jun 2022 17:49:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@themaw.net header.s=fm1 header.b=XYOvYhtl; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=NVOLqdKy; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229751AbiF3AqW (ORCPT + 99 others); Wed, 29 Jun 2022 20:46:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229454AbiF3AqV (ORCPT ); Wed, 29 Jun 2022 20:46:21 -0400 Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5911340D6; Wed, 29 Jun 2022 17:46:20 -0700 (PDT) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 22E345C0397; Wed, 29 Jun 2022 20:46:20 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Wed, 29 Jun 2022 20:46:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=themaw.net; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1656549980; x= 1656636380; bh=YGkknG7f4f40yQzuN+h1Ss3pBCm01aDX5rQ1G2imCNI=; b=X YOvYhtlD2DjI4WwEt487w47x2rOcAYx1QLMH2wI7rnFvXpJonKhtIEXIjetpYvdT FT6stHT/9ll3sDA+Nl17e9TU5dn4S/HYD/A8sQxUD/Du0tFEra5sKUkinCUEl9rZ I3i2mq6zE2KkjX7B4uLV/14LSGylCfhzjd/4rlcDHHfOQ0qF+A6KcX5jK+1w76oP 7Lvh1fb7TXdbbIFby3/xQI9YyNNqOempl27NUWBFpoF8Gna66UFtegV2ubVlzqTr Ng8X1oM0528EkS8zeJRdqwgkA2z0dGOzFf4i4QDQm0KJv0B1PMfjRKDcirfvZagm SonxaTVlLU4G54K+s873g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1656549980; x= 1656636380; bh=YGkknG7f4f40yQzuN+h1Ss3pBCm01aDX5rQ1G2imCNI=; b=N VOLqdKyc3pdKtG4iKvLvOXZdC1/ZVw4QELKQbmRkI33dgQd9UcBvYm6N2mNqIdMB V6jEjPnsUd3d0Qo1neBs+W8T3Ls8yUl9jAz5cCy+V1LOv2ndVM+xWuhDuRiT3Tf5 To6QOu+EnYdwbZMobpRC0yDwjNto4CdKft7ngSe4D2R30KVwJeaejph5ILJJTL7C ucPvIADlLhbSvxNpUsl9auaFKnxbE2Q5ahnj3sKL7j9ulIyygJ5sdsmKsINzpGkJ 6EC9Zw90/LxNszBbPe27I0UlzOW8LbP7lPeMTYE1OqIIXajMmrV8PEhS2d4kbyvr 1JpeiDPRqePmRRd6gDynw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrudehtddgfeekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffhvfevfhgjtgfgsehtkeertddtfeejnecuhfhrohhmpefkrghn ucfmvghnthcuoehrrghvvghnsehthhgvmhgrfidrnhgvtheqnecuggftrfgrthhtvghrnh epieevleekgfdtgedufedufedtleetjeetvdehueelvedvleeuhfdutdeigeevleeknecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprhgrvhgvnh esthhhvghmrgifrdhnvght X-ME-Proxy: Feedback-ID: i31e841b0:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 29 Jun 2022 20:46:16 -0400 (EDT) Message-ID: Date: Thu, 30 Jun 2022 08:46:14 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [REPOST PATCH] nfs: fix port value parsing Content-Language: en-US From: Ian Kent To: Trond Myklebust , "Anna.Schumaker@Netapp.com" Cc: "linux-nfs@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "SteveD@redhat.com" , "bcodding@redhat.com" , "dhowells@redhat.com" References: <165637590710.37553.7481596265813355098.stgit@donald.themaw.net> <891563475afc32c49fab757b8b56ecdc45b30641.camel@hammerspace.com> <2dbeb7b8-8994-d610-f536-58d41767a1ec@themaw.net> In-Reply-To: <2dbeb7b8-8994-d610-f536-58d41767a1ec@themaw.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On 30/6/22 08:41, Ian Kent wrote: > > On 30/6/22 07:57, Trond Myklebust wrote: >> On Thu, 2022-06-30 at 07:33 +0800, Ian Kent wrote: >>> On 29/6/22 23:33, Trond Myklebust wrote: >>>> On Wed, 2022-06-29 at 09:02 +0800, Ian Kent wrote: >>>>> On 28/6/22 22:34, Trond Myklebust wrote: >>>>>> On Tue, 2022-06-28 at 08:25 +0800, Ian Kent wrote: >>>>>>> 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 >>>>>>> --- >>>>>>>     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), >>>>>>> >>>>>>> >>>>>> Why don't we just check for the ENOPARAM return value from >>>>>> fs_parse()? >>>>> In this case I think the return will be EINVAL. >>>> My point is that 'sloppy' is only supposed to work to suppress the >>>> error in the case where an option is not found by the parser. That >>>> corresponds to the error ENOPARAM. >>> Well, yes, and that's why ENOPARAM isn't returned and shouldn't be. >>> >>> And if the sloppy option is given it doesn't get to check the value >>> >>> of the option, it just returns success which isn't right. >>> >>> >>>>> I think that's a bit to general for this case. >>>>> >>>>> This seemed like the most sensible way to fix it. >>>>> >>>> Your patch works around just one symptom of the problem instead of >>>> addressing the root cause. >>>> >>> Ok, how do you recommend I fix this? >>> >> Maybe I'm missing something, but why not this? >> >> 8<-------------------------------- >> 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; > > > Right but fs_parse() will return EINVAL in the case where a valid option > > is used but its value is wrong such as where the value given is negative > > but the param definition is unsigned (causing the EINVAL). > > Of course this case is checked for and handled later in the NFS option > > handling ... Oh wait ... I think I've been too hasty and not understood what you suggested ... let me ponder that a little ... and thanks for the suggestion. Ian > > > There's also the question of option ordering which I haven't looked at > > closely yet but might not be working properly. > > > Ian > >>         if (fc->security) >>           ctx->has_sec_mnt_opts = 1; >>