Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3481530iog; Mon, 27 Jun 2022 17:35:56 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sRqoVdu0snCueRshqDYnDiFPkQl88isclGX3N35sBta2hGhOWF37WBkbafvLab3jdkQULM X-Received: by 2002:a05:6402:2396:b0:435:775b:b136 with SMTP id j22-20020a056402239600b00435775bb136mr20509011eda.299.1656376556506; Mon, 27 Jun 2022 17:35:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656376556; cv=none; d=google.com; s=arc-20160816; b=dUhhIF0IYFM1OjYfnhbAa8IbRct9YmPK5a9WULlz0hXzXtpQPjEfm/eH2blF6OmV+E WSXm6MDwZEC4zhDSli1ME8yDUMT6e7asIw2ZC+2ZRqp7+j7hvwTKWEm4Oo3fWvDmaA0D c3pHBNXywjnFJLHYODXmhnCRXmBGDsDA/3De275MjwLDJfuZ7OU/Dv2E5zfT2X4aFd1x Px2YQ9UcQA5bWRFAGw98p5t9cBvNVKF+1E/Polm8IikfU0SKjoP2UgrF4giGDAAyzP7/ iH9mwMzvnPHiNPSV54++dfEoJScV1xWFMygaygQbGqFpdxw6LH0bMLlbxdj1XB1H6lLq 5Hzg== 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=P1iGLnjWhx2ZM6mBiPRPeymOEz52vyfY0oMcyTh+F1w=; b=aGT64Z1ABVa9+fNpuYrpSn0ydOASJXfsu1rPd+fFbZCmRujbh/7ZaMLRJZ00C0w+5N l54zI5IRZn4IAWS1O36rJoffbKuojFvTDXAHHqf38ibIUzAxKouwTylUeiZFumwO333b e3N2TJoZvEndiUBGhGY8MgASDSxKB/LMhAF2NgmURojgAFoa0mT12xV5xVOukpb8PJh6 j6gdydpDc/VIttO45+txyXKa34s8gMueZy5wZ5xNkOd0ZUSdTXYclvZB5Ub1lTXPFoT8 R3K+VKIlC88O7sK4YuqQpA9PQ42hYcWqrBCiCpc5Itp1b0jvHR9Nx4swB+BA2ColizJp Tt3w== 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 y16-20020a056402271000b0043770f4e810si206621edd.217.2022.06.27.17.35.18; Mon, 27 Jun 2022 17:35:56 -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 S241941AbiF1AfF (ORCPT + 99 others); Mon, 27 Jun 2022 20:35:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241899AbiF1AfE (ORCPT ); Mon, 27 Jun 2022 20:35:04 -0400 X-Greylist: delayed 590 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 27 Jun 2022 17:35:04 PDT Received: from smtp01.aussiebb.com.au (smtp01.aussiebb.com.au [121.200.0.92]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05EC413CE8 for ; Mon, 27 Jun 2022 17:35:03 -0700 (PDT) Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp01.aussiebb.com.au (Postfix) with ESMTP id B7645100506; Tue, 28 Jun 2022 10:25:09 +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 wKebxycWQ06H; Tue, 28 Jun 2022 10:25:09 +1000 (AEST) Received: by smtp01.aussiebb.com.au (Postfix, from userid 116) id B07F9100545; Tue, 28 Jun 2022 10:25:09 +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=unavailable 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 861E5100506; Tue, 28 Jun 2022 10:25:07 +1000 (AEST) Subject: [REPOST PATCH] 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: Tue, 28 Jun 2022 08:25:07 +0800 Message-ID: <165637590710.37553.7481596265813355098.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. 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),