Received: by 2002:ac0:cd04:0:0:0:0:0 with SMTP id w4csp367911imn; Fri, 1 Jul 2022 17:34:20 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sbE9rhUBDav8jaKL2IzWPFNmNsLdPnfcSK1G5nbkPK2Jw9h7h5cQ6zE8HPzeSOuQLAUi9w X-Received: by 2002:a05:6402:3514:b0:435:f24a:fbad with SMTP id b20-20020a056402351400b00435f24afbadmr21568686edd.311.1656722060133; Fri, 01 Jul 2022 17:34:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656722060; cv=none; d=google.com; s=arc-20160816; b=zcPEgZbKP4q06pComE03BggMHb655V3safGLCs9zyARkplCOULLySyT8ZZHRNVQ53q K/or1HtrASzPcLOrJkdmIt/KsDaxzPDUXRGGLCRTKCuso5zjwHGogFUYuQOmp5F+5VaK RtbraIuRpc747QGtWRE/94GnZXkFAQX78Pj9Loa/TTELzPH+1eygjFg3hgTNYpTKpvFD ETZZ4gNxv7xYhuOd4XceMqKjAY1YkRh6lcuPP/PPiyFsedPQrGCPeXCioK8qlhP7KXo+ n4/B3rYxTbWiaswGgGcWaLSLuluVBkCCwgyJ7849+HwOqNRGb9gAzOk1WXDR1z3lpJxb EK8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:message-id:date:cc:to:from:subject; bh=xkufTWdpCiKADMKcRzpFPDvyopoeGxbTIi+YPxMTS64=; b=iYBU/IIxFyq9BjJgymRNTzzA5l0/UTwJ3zhNs4xw7hoiLqpaid25N3hSlvU9tU9qfa 9c+q2Dso3a0W9e0zgAuSpQk93iULra9/p1qbnQx3ThZiA5XhY4NfB9EweSCgVmHiND4j NiXnbAenyHFnXS6i6U1l1IrI+/pwv1y7t7N885+tnQlFSxnZAloJOguR4jaSpXpIDDJw C2dfcpaGN4LeXFikuusLknHIrNidh0K80bIyyT6e35JdECcoXdvkIBSZOiLvTmNQdcGe MHGxmaiGxC/36SizKeBkbWA6KViKXVUndousenbggQx4ooSjN2ly64FZyPVwnOzAJVRk Hn0Q== ARC-Authentication-Results: i=1; mx.google.com; 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 v6-20020aa7d9c6000000b004356fb37af6si3033602eds.44.2022.07.01.17.33.38; Fri, 01 Jul 2022 17:34:20 -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; 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 S231209AbiGBAX4 (ORCPT + 99 others); Fri, 1 Jul 2022 20:23:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230452AbiGBAXz (ORCPT ); Fri, 1 Jul 2022 20:23:55 -0400 Received: from smtp01.aussiebb.com.au (smtp01.aussiebb.com.au [121.200.0.92]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D2C73983A; Fri, 1 Jul 2022 17:23:54 -0700 (PDT) Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp01.aussiebb.com.au (Postfix) with ESMTP id 91A28100801; Sat, 2 Jul 2022 10:23:49 +1000 (AEST) X-Virus-Scanned: Debian amavisd-new at smtp01.aussiebb.com.au Received: from smtp01.aussiebb.com.au ([127.0.0.1]) by localhost (smtp01.aussiebb.com.au [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id KqzllykxvaJN; Sat, 2 Jul 2022 10:23:49 +1000 (AEST) Received: by smtp01.aussiebb.com.au (Postfix, from userid 116) id 88FFF100617; Sat, 2 Jul 2022 10:23:49 +1000 (AEST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 Received: from donald.themaw.net (180-150-90-198.b4965a.per.nbn.aussiebb.net [180.150.90.198]) by smtp01.aussiebb.com.au (Postfix) with ESMTP id 99932100534; Sat, 2 Jul 2022 10:23:47 +1000 (AEST) Subject: [PATCH v2] nfs: fix port value parsing From: Ian Kent To: Trond Myklebust , Anna Schumaker Cc: linux-nfs-list , linux-fsdevel , David Howells , Steve Dickson , Benjamin Coddington Date: Sat, 02 Jul 2022 08:23:47 +0800 Message-ID: <165672142729.19075.11075272196311507440.stgit@donald.themaw.net> User-Agent: StGit/1.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org 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 --- fs/nfs/fs_context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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;