Received: by 2002:a05:6512:e85:0:0:0:0 with SMTP id bi5csp35413lfb; Wed, 29 Jun 2022 16:36:51 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tRhgHODDbOwwCpQcfPW7LHnOyDh/Udmdm7u2l+bUALtyF9tpabBctUsR9NnuC8rkhLTf5X X-Received: by 2002:a17:90b:4a82:b0:1ec:bb6b:38ce with SMTP id lp2-20020a17090b4a8200b001ecbb6b38cemr8549581pjb.149.1656545811060; Wed, 29 Jun 2022 16:36:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656545811; cv=none; d=google.com; s=arc-20160816; b=m9XriI6ruScLqnjHvDQkg4Nqn/AfX4cc64va00mZUIoVwQue57YdwsSPTsPHJVkcVH u7MgL8/oIsGpB0OWbgF3aE4otfAk9QIM/5Kbmz2wU5Qk0wzrwDaEMDQ2qNElLJLTuTEO 3Vz6OzWFzhDfARZUxGAY4tgsZ7pns3Gu6qs3WcN3gVDqt1/oTfVE/LN7409mZQEOdHrk iPlD97Xzkp1KKkqdElHv8UrTbUrbrqADSa9aWzWm27CmQ9A45exYAIqPO74I9C8Wq1SN iN2wBaYvRmzb8dnWvPrbw7mGp6a16eNLDSoi5PalpFWFN3c/95sXuK4UbkyEo2oTA8TX SOIQ== 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:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:feedback-id:dkim-signature:dkim-signature; bh=noYt84Jd7q+oGWxeTJZpYrHP+Dz1u6A7BigbFhMFB70=; b=P/+O3jM11xNj1co7Sxh6zUViikvjeTvjVUU4Zsx8JgtPJplBip7FbXF5SN140/ZrXm ILqMhm/+f3tfKrEvpwFMMDchTl6Q/Ade7Os74+S0M8QwEzIqfhypR3OVwiI9SirnE7Xw GcmeHbLWhUFpTJQnsOqwCyTvL6OxVyHxLCSH5KWhwwjho64z0n367JMZ2j+sXe+2GBos W7LXgDzo1icLGZqlXByL5h4/YCF92Qz81a6F7QJniAXVIsKIlk8SEWn62tWk6GHPtW6R QSC+FxnHT+IcWtCqElyedbAdFunH4WhTmEoHCLSCyBzydSHBHsDL+A0T7OecF1vcQeqi AhMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@themaw.net header.s=fm1 header.b="IkXy/+6m"; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b="PULmk/1C"; 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 cm26-20020a056a00339a00b0052801ed2306si2501893pfb.142.2022.06.29.16.35.50; Wed, 29 Jun 2022 16:36:51 -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="IkXy/+6m"; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b="PULmk/1C"; 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 S231919AbiF2XfC (ORCPT + 99 others); Wed, 29 Jun 2022 19:35:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231847AbiF2Xe0 (ORCPT ); Wed, 29 Jun 2022 19:34:26 -0400 Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D02C440E72; Wed, 29 Jun 2022 16:33:59 -0700 (PDT) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 1CAF65C0470; Wed, 29 Jun 2022 19:33:54 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Wed, 29 Jun 2022 19:33:54 -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=1656545634; x= 1656632034; bh=noYt84Jd7q+oGWxeTJZpYrHP+Dz1u6A7BigbFhMFB70=; b=I kXy/+6mJ2h5+DucoiNAslvxJxcREuKufNf1U1j0pEO7i9kuZhXO5K2y+zPMSTFX0 Jixh3/L1i+xewqfUbZ2jzwQV+qslQlj/2K4DzbymDwFXziCNzXCw7AH40Lca0ZMf RF3FJW5pNlIaegjH5SAVwkfNl8ZGEG6gUZrFuoZwCS90uSk8jKXcQWIeV9cEd8dZ wgQDvcMBvTQ2rr3HtINkoA/sSYcN9E3fxMcHZVXOHOGxbTgh6aVDuWO2lYvZNbsf lRLuHB2uh3I6ayQQAH9NWHdvw+z5ZqsXmmGoE44eoiOyBMmegntESitYSZajiIlQ REUQG00fFoN0x8qAEggmw== 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=1656545634; x= 1656632034; bh=noYt84Jd7q+oGWxeTJZpYrHP+Dz1u6A7BigbFhMFB70=; b=P ULmk/1CXKH55EQzWRlHgJK9ReLtP2S7b4pRk6gbh0N++p2dc9/VM4603EJyX9AJH n1VWOMju2YxmXCEKn5HFsm4LU3tR2ahalwZat1fz2T7fTQid0rX6vVl/ZT9g3hc/ mTCTOmawy2sizw5y4NCa7fDcPGfbSnj5q58dhmgQ5HPZoau5DVG5J5CFmM2o4NWo hBDHlZspW/FIcbjLioei0TQFkqIeBdmcF8RCRY3saSnGffB5732rGQk3GsdzcE82 BWhOGaOJCVOJvEi0h4SU75KRVQ0r2gRkJPQTZlT1rbt7eRq6vq3s4hvxUMktMvo3 gl2A2u7VXbxZ0UDOwo21g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrudehtddgvdefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvvehfhfgjtgfgsehtkeertddtfeejnecuhfhrohhmpefkrghn ucfmvghnthcuoehrrghvvghnsehthhgvmhgrfidrnhgvtheqnecuggftrfgrthhtvghrnh epgedvteevvdefiedvueeujeegtedvheelhfehtefhkefgjeeuffeguefgkeduhfejnecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprhgrvhgvnh esthhhvghmrgifrdhnvght X-ME-Proxy: Feedback-ID: i31e841b0:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 29 Jun 2022 19:33:50 -0400 (EDT) Message-ID: Date: Thu, 30 Jun 2022 07:33:46 +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 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> From: Ian Kent In-Reply-To: <891563475afc32c49fab757b8b56ecdc45b30641.camel@hammerspace.com> 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 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? Ian