Received: by 10.213.65.68 with SMTP id h4csp2119353imn; Sun, 8 Apr 2018 20:11:00 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+3h07VPVCEy9IzmELMvb6VwPsRmRpYG6MJDFe4OQ+kNrqmkcWFl1CZHuBNq34w1bw9Fz6E X-Received: by 10.101.102.211 with SMTP id c19mr13375741pgw.78.1523243460143; Sun, 08 Apr 2018 20:11:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243460; cv=none; d=google.com; s=arc-20160816; b=YPXjYp91gBDqBhEGLhCM08CPi4wi9g95HRu2kHCkeDn90ogiFis7acStxHto+QMxCu kN+la3K1+AaW96OYZIdsw/RVLQo4QDyWjcBhlAEJL2XwRUqCpvwFZS8jl80+LFMWGWf4 aKst3C6qf67qxlBxJ79JHJn+14gWmVVhjN/c3hTc1uuKX7iUPh7q54MXkn6sYp+8SVjh cxSdjUPJ2ike2xeWNDdFq6GEOJRgy+afizPhoZeGSh1CL1CrN3lUG2G2UBhYjRTrKCF7 WKbjm4h28FctRqRW8X1+ze+CJ/DnU2jVfH5tC3RWiXZH1meSDI3qeMCz5HJ72PDcDut7 WEHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=pQE6Aukk35LhxkF+aeVmwkc/pFlnLSO2mfos5De9D+M=; b=CPNDGWmGCPlX7eE2GJeLd4bXehF60AMVaCx8lhwzOj6WSSkoH9IGA/MQsoW8e5n27R hxuXCJB9XTmch2Yz1gcmZ+shTkdpHQmcCjFwEzj8s2fUrvtKtRfQMvNWvQFwdW31UYvJ +rCUz/siRmQzetXMr1XkWXu4BuLdQKDJT1xKnKamKHptAXslOvCXkiQLG/U/RRo9Ozsq pRAjv3XhlmVLM6m5499xfXgM3ruZL26SvpfTi9Ox8GoOQgbZ19F9Ia3bXWMU4cknUQN8 Vl1uhJXC3GFZZToNe2jAg05+nBUQw8dfZzVrQibTu33439EgPX6mfyuh3R7OV9kp2qKR LPNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=PI2xsGa/; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f67si6261326pgc.114.2018.04.08.20.10.23; Sun, 08 Apr 2018 20:11:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=PI2xsGa/; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755695AbeDICyI (ORCPT + 98 others); Sun, 8 Apr 2018 22:54:08 -0400 Received: from mail-by2nam03on0131.outbound.protection.outlook.com ([104.47.42.131]:4960 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753097AbeDIA0Y (ORCPT ); Sun, 8 Apr 2018 20:26:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=pQE6Aukk35LhxkF+aeVmwkc/pFlnLSO2mfos5De9D+M=; b=PI2xsGa/ZPu2FBBasGMC8/I73c1Weik7/vVHnpQOhhRheiN5bVjd9Fmk2W62lvV1GHNuY5L1R5mqs30InTYFvtQQ7F1JGh9YrBWlW9IzWH/FkqiGGW72w+EalFsC9Ou91zccOD4K6a9WN0JjI0nf4i2EpDgFbunPQxNQj9DbnXU= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0725.namprd21.prod.outlook.com (10.167.107.167) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.0; Mon, 9 Apr 2018 00:26:16 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059%2]) with mapi id 15.20.0696.003; Mon, 9 Apr 2018 00:26:16 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: "J. Bruce Fields" , Sasha Levin Subject: [PATCH AUTOSEL for 4.14 142/161] nfsd: return RESOURCE not GARBAGE_ARGS on too many ops Thread-Topic: [PATCH AUTOSEL for 4.14 142/161] nfsd: return RESOURCE not GARBAGE_ARGS on too many ops Thread-Index: AQHTz5jA+2mAWy0jdE26p8POo3Iq+Q== Date: Mon, 9 Apr 2018 00:21:49 +0000 Message-ID: <20180409001936.162706-142-alexander.levin@microsoft.com> References: <20180409001936.162706-1-alexander.levin@microsoft.com> In-Reply-To: <20180409001936.162706-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB0725;7:oqrAkIhntaySrRohkLhuA20gZfHCivcSXJgCNtkuoA/d/kx2tBuRDEXjyMxQTkrPFnoalIQ30Pm0Vs5lZ0BILV/n7rVb8rFgZxdS5/Pcl/OIlCkke8hBTIuFx5FHgMnZ12eWShl5ei1774EqFo5SSSVvoDryTPJ+muHfaFiocsCLpMbehbusElcD+R1Ykz0wttNwCwx8l2PIYzvj3qKWNf+newCqDdwdYSG8akZoxgoWDch9H95lDyrnI44iSJJf;20:Sf9hQX+iGc8nGTGD9IZqsou7DNzP0dQNtRLVCpkK/FGFND4/SwHF8k19nR1jI4o/VBHf8zRrSj8aRvFphRWBkhN/4xEqCCOVd5ZyYEfbH4/Ju5mwh/ZB2xISZTEhog5o2b4rginynhpmxXIAA+uA1gbL0mCkx+zb3wjnvWjLvzU= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 8a1063db-1ac8-4205-53c9-08d59db081e3 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0725; x-ms-traffictypediagnostic: DM5PR2101MB0725: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(170618885588394); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(5005006)(8121501046)(10201501046)(3231221)(944501327)(52105095)(93006095)(93001095)(3002001)(6055026)(61426038)(61427038)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(20161123558120)(20161123560045)(6072148)(201708071742011);SRVR:DM5PR2101MB0725;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0725; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39380400002)(346002)(366004)(376002)(396003)(39860400002)(199004)(189003)(6486002)(81166006)(26005)(6512007)(4326008)(6666003)(6436002)(81156014)(8676002)(97736004)(186003)(36756003)(72206003)(53936002)(107886003)(2906002)(86362001)(76176011)(110136005)(305945005)(10090500001)(486006)(3660700001)(102836004)(5660300001)(14454004)(476003)(86612001)(446003)(99286004)(68736007)(66066001)(11346002)(54906003)(2616005)(1076002)(7736002)(5250100002)(25786009)(8936002)(478600001)(2900100001)(2501003)(3280700002)(105586002)(59450400001)(316002)(106356001)(22452003)(6506007)(3846002)(10290500003)(6116002)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0725;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: NIEyfoXbf3u4KHfU2tOiFdmshLdl1GkXFgZuDZukOouchTCMBSvbLspeAhkihelmltDo41Ei0ymermhsQw9zEL8bqA6RosQXOeB4A+Un2g79SGyHsCM5IXlSQZMcFOu7esRrp7zATwyj2V+tf3IoyZUU3FOaM85Z0SOlZNRJVrUJdTDF69e5zIR1VbkHHVNya+ABmLt8K5AwlYV+ntAwcK3jvPEj1iijFrvfMcXo5nYaNgsU0RyidbKxSy6KHcACYjuDnbmeR27KDCaZ3R3GMqbGsbIwNmZInvneb2I5Hren0m2iuY1HU9IkzRh6BrJcF+nvmvu8w67OAaaTccoUqymqfoqvNv/6+6q6Ftxaq0TvsYAeVDcJxqAW0U1bLMvNtfWZU4b0u9WExue3gg+KKdrT2GO2rqylIq5hBAsQAjI= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8a1063db-1ac8-4205-53c9-08d59db081e3 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:21:49.3311 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0725 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "J. Bruce Fields" [ Upstream commit 0078117c6d9160031b866cfa1853514d4f6865d2 ] A client that sends more than a hundred ops in a single compound currently gets an rpc-level GARBAGE_ARGS error. It would be more helpful to return NFS4ERR_RESOURCE, since that gives the client a better idea how to recover (for example by splitting up the compound into smaller compounds). This is all a bit academic since we've never actually seen a reason for clients to send such long compounds, but we may as well fix it. While we're there, just use NFSD4_MAX_OPS_PER_COMPOUND =3D=3D 16, the constant we already use in the 4.1 case, instead of hard-coding 100. Chances anyone actually uses even 16 ops per compound are small enough that I think there's a neglible risk or any regression. This fixes pynfs test COMP6. Reported-by: "Lu, Xinyu" Signed-off-by: J. Bruce Fields Signed-off-by: Sasha Levin --- fs/nfsd/nfs4proc.c | 3 +++ fs/nfsd/nfs4xdr.c | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 8ce60986fb75..8706b141e4a4 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -1712,6 +1712,9 @@ nfsd4_proc_compound(struct svc_rqst *rqstp) status =3D nfserr_minor_vers_mismatch; if (nfsd_minorversion(args->minorversion, NFSD_TEST) <=3D 0) goto out; + status =3D nfserr_resource; + if (args->opcnt > NFSD_MAX_OPS_PER_COMPOUND) + goto out; =20 status =3D nfs41_check_op_ordering(args); if (status) { diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 2c61c6b8ae09..5dcd7cb45b2d 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -1918,8 +1918,13 @@ nfsd4_decode_compound(struct nfsd4_compoundargs *arg= p) =20 if (argp->taglen > NFSD4_MAX_TAGLEN) goto xdr_error; - if (argp->opcnt > 100) - goto xdr_error; + /* + * NFS4ERR_RESOURCE is a more helpful error than GARBAGE_ARGS + * here, so we return success at the xdr level so that + * nfsd4_proc can handle this is an NFS-level error. + */ + if (argp->opcnt > NFSD_MAX_OPS_PER_COMPOUND) + return 0; =20 if (argp->opcnt > ARRAY_SIZE(argp->iops)) { argp->ops =3D kzalloc(argp->opcnt * sizeof(*argp->ops), GFP_KERNEL); --=20 2.15.1