Received: by 10.213.65.68 with SMTP id h4csp2118226imn; Sun, 8 Apr 2018 20:09:31 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+/eRrCV+nCsJ9mymBFmEXYOPtPZhS9bbUVD1WY4shM8A9WjU0+IogZ4nQTpV2WLbfoyIb1 X-Received: by 2002:a17:902:6085:: with SMTP id s5-v6mr36988636plj.307.1523243283781; Sun, 08 Apr 2018 20:08:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243283; cv=none; d=google.com; s=arc-20160816; b=gTd8cOmr2gM5LzEjDTSQEpFaPQdAaCjZmYyfe0MbRe8Q9uAz+62Jgb5PshmvW9QXW3 fJ1DLLzhBR1GoAaGS+4FvSl0SWohJACsKjozJPq3WbONkq3hw/+OvfUrv3L1jBgyS0xB Ry8H3rBpFZbFcBBW28+Oebkl3pJQa/frm8i2EL8vrPE/EdfeUqVFk6U3wJhypkjU27um uxWFzHjWHjMqwJ0mbblt4HuunrPrHkanqwHAGR9NJnsbEoa2ouW2khLu5/sOOt0yuW4Q 88A0QHafyZ/ZgMJKg/k6zJ5Quxmdkby7sxNGvfFJPEYBgVz5lHt43lBsiISUgulLD/sK shZw== 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=Rbw1u7mpmJt+dQSrzx9621bahMBQTHai9wojpMNaDO4=; b=wY9o1BBRgBNC0Bu3F4nM32tSQWWpJuSfQrGSe2dFsekKS17vJ8AU/0U00Rku+kNKig imi6euKe2pciEYknPzyWhYoN4YB0pBQ63wvtip0UiuDczE/gzOI5uD9DkUe5gkoWU6YF LZR6uwp9jo+p91D9MSSps4XFNqrQgs1TvdVYG8cwreKq8xXSiATW6NUP1268kn22ZTaS GpQnEp4/RuClktwZVCsJY/1/udznRD4Ph7mmkOQrdjBVhB8lKm47D6nb+O+Jgn5x5iE1 vax0pflX/eqT4sBFD3xZx6seK5or9QdbUFFCrriPMzDnxXb2RhZ3F+OOAiu1ToMg8MxJ b7sQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=Q021OaI1; 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 p7-v6si7799389plk.159.2018.04.08.20.07.25; Sun, 08 Apr 2018 20:08:03 -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=Q021OaI1; 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 S932902AbeDIBmj (ORCPT + 99 others); Sun, 8 Apr 2018 21:42:39 -0400 Received: from mail-by2nam01on0123.outbound.protection.outlook.com ([104.47.34.123]:51296 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932520AbeDIAer (ORCPT ); Sun, 8 Apr 2018 20:34:47 -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=Rbw1u7mpmJt+dQSrzx9621bahMBQTHai9wojpMNaDO4=; b=Q021OaI1vD/X/8Gbx29qKHq7bYTvY7muDzjBdk0rbJhL0CnYKMVA1bWTMXBdYCiXkSMfbhT8xu73OA0G/B3Xm8TQ9QoTGn5JwSBnS50zPTDnJRe3+baAnb/+tIYk3eC4dLFPF1QHl+RkxDuUD/JeiecylcsI+tsdKuSz0hJmLNw= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0806.namprd21.prod.outlook.com (10.167.107.156) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.3; Mon, 9 Apr 2018 00:34:43 +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:34:43 +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.9 285/293] nfsd: return RESOURCE not GARBAGE_ARGS on too many ops Thread-Topic: [PATCH AUTOSEL for 4.9 285/293] nfsd: return RESOURCE not GARBAGE_ARGS on too many ops Thread-Index: AQHTz5lsxQPqL8wNZEeEE0A45H9ryQ== Date: Mon, 9 Apr 2018 00:26:39 +0000 Message-ID: <20180409002239.163177-285-alexander.levin@microsoft.com> References: <20180409002239.163177-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002239.163177-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;DM5PR2101MB0806;7:LFf7FyngTZcq6cQL4hZE70enLiEj4aHqZZd2AjYhX8WvB0lo3P05bwwZD68HCs/zojeR8Bl/b0fvOX3rzzvtsjQkHSYkyO1e2f7V4SB/kzzZCZxGLVg3lITfg0ShhUT5HX59vhtjqpGqtqUz/8qqj8VFhZzZ4kd0/P3ji3KV/+9uIs+Ggo0+i0/nzNb3gFD6DdOPrizVTvMHvCMsDUbFXNhmZ3pjU9xF7hH0vuMUM2d17Fejh3GvBoITCqKsQghg;20:0GFOO2aK3fhu0ENGJFKWI76vISA8szNu3lS2+N4OLcMqGEt3J17L0tPh8SQ/Qa8vOwEMekdF1uXKwWiaUdabimX55mZbHT7vtKWiCuVXUW0iEUTeb6FxNgBvNefYlOK5buIUcI2jpfpInAEX01ciW4SPnTkdkWaHzFfS/M5VOEk= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 00ba1dd2-768b-4113-899a-08d59db1b068 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0806; x-ms-traffictypediagnostic: DM5PR2101MB0806: 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)(8121501046)(5005006)(3231221)(944501327)(52105095)(93006095)(93001095)(10201501046)(3002001)(6055026)(61426038)(61427038)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(20161123558120)(6072148)(201708071742011);SRVR:DM5PR2101MB0806;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0806; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(39860400002)(376002)(396003)(366004)(39380400002)(199004)(189003)(2906002)(25786009)(2501003)(10290500003)(476003)(11346002)(446003)(97736004)(5250100002)(68736007)(2616005)(102836004)(6506007)(59450400001)(3846002)(3660700001)(486006)(3280700002)(305945005)(6666003)(99286004)(5660300001)(76176011)(1076002)(186003)(26005)(7736002)(6116002)(81156014)(81166006)(86612001)(4326008)(105586002)(10090500001)(2900100001)(54906003)(22452003)(316002)(36756003)(110136005)(107886003)(8676002)(6436002)(478600001)(53936002)(66066001)(6486002)(6512007)(575784001)(86362001)(14454004)(72206003)(8936002)(106356001)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0806;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: +hPtWzGz0V8+gnc6d4QxmVllPIaBz3U8x7/0a1B5PAP3EeIp4Ok/3u3Ix2BHnM+Ot7pDtkhtf8S2en9eJ3V2UbDnjw7rDBsSkHsdlnDVzH08Lv/qzy4ab5IsVk2nnvGbhVGsny4KGUu91eOGunBmCna/NoCdJEhxNkcBZ3rUaFix/vp3UI9bTEx+Z488B0osB6u+zvVhwTxtQEjSpKTeE1BOn6a6fVVzky6Sl92FbY3k2yelZGPepfBm80XfX/MhqrZATEEOJNkkfa0sk2oSazmTMFkyTRi7TQJmirGpLs8dV6NOGBivA/qxbi9TxK++zvaDF91bHmVMMiqzu5T4gmh4EsHOZ8edijRZL8q7b98HRotqNjkIVPZIDbvSYUgX56vNRZi/YZbqloHL6TGAlsTKMja0BTF8je5mOaALP1w= 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: 00ba1dd2-768b-4113-899a-08d59db1b068 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:26:39.0196 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0806 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 eef0caf6e67d..ff414a9d77ed 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -1720,6 +1720,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 2c4f7a22e128..940bd8232a9c 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -1866,8 +1866,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