Received: by 10.213.65.68 with SMTP id h4csp2142150imn; Sun, 8 Apr 2018 20:47:53 -0700 (PDT) X-Google-Smtp-Source: AIpwx48IbZ1xPIvocA8Ay622gVKnVaea6vzJUohvRnq5Pxk89lCtQESoOdpVVK0cfh3aPd8TZKtR X-Received: by 10.167.128.194 with SMTP id a2mr9760863pfn.130.1523245673052; Sun, 08 Apr 2018 20:47:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523245673; cv=none; d=google.com; s=arc-20160816; b=TkQfYLKZOTE1s//IkSScE5reHBHaCzeci4IWHTG0isN9rd9Q7Qr5Y/BFlNeCcy4FFP OSzn3hxiBzZ+0gbWpcXDupqJ30f64zHKRnXSOgVZQntx0gsZSF4sqIrIeywn9uxmbXPT TvVb1zeQXR8ctyiw+lzYJGyEh4sAMLPeUzoUHFFz5mVOSpK+SE5bmEb1+tvMV0gUrwAw 4ax3VcaUSu6d8hTmpz2I7C4yn57tXPAEmHcIdqFYDIDAaatl6n5x6kqTr7qZRHqsNMir /1jbvuTdRLMfF0OqSeoITz9+I6MH4ehfMsAOFeHriGF8mbSS6ZvPXip7dson9RHWeamu hmIA== 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=0ZUUF3pAKfBvxDpvEaQIrJDJrz9WBpgUZc+MccRexNA=; b=Hy5dm0TC0ghwa8F93zSDL4R2my30uC5PKD/txlJM4iNb1W6KHM1hf2SZJewsdeuLE2 5ex09l3rFLFccuBNLt0O3SWYSzWcUl98+r5vL3tfEGCHcBIYYuM4SnbRUZdXkQ15BfX+ A9g1vDD2BSoI9UNHE9NCMcEDjeFAZJJmU+ZWjMf0zLgsD5cn+310YKMHrUKhNSHO1xVn cpwy6+V2/tT6OF0jXq1ukDn/AZZI9xjjPIdP5meyB/H9jiU7DObPg8fDRew/tJ8TdaDg O3DtsNLwO6/jT34jzckgRYytytcs8JN2W2DqBwnLKXJlP1ksPGVWN13F9xz3TNpPbkvo HLiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=UJC8jW4+; 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 h23-v6si1506695plr.576.2018.04.08.20.47.16; Sun, 08 Apr 2018 20:47:53 -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=UJC8jW4+; 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 S1754771AbeDIDgj (ORCPT + 99 others); Sun, 8 Apr 2018 23:36:39 -0400 Received: from mail-bn3nam01on0108.outbound.protection.outlook.com ([104.47.33.108]:54803 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754387AbeDIAVL (ORCPT ); Sun, 8 Apr 2018 20:21:11 -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=0ZUUF3pAKfBvxDpvEaQIrJDJrz9WBpgUZc+MccRexNA=; b=UJC8jW4+6fV2aVZ7TXj9Fd5XS9ljJ+UZZho/UMAPyqITVHbzxqrWGNCnDAeAps56DcHJRG/xN9RcW/S3ikB7dqCH/hXeXvzOV2z4ZK8WF3YHZiUkD5K4f6Kv6xzlkj6dKOymQJuBawJLaHL3CcUG4qeOVnbmcDXKBNbJh2Z+UhM= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1125.namprd21.prod.outlook.com (52.132.130.150) 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:21:09 +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:21:09 +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.15 168/189] nfsd: return RESOURCE not GARBAGE_ARGS on too many ops Thread-Topic: [PATCH AUTOSEL for 4.15 168/189] nfsd: return RESOURCE not GARBAGE_ARGS on too many ops Thread-Index: AQHTz5hccPWfIEumc0Gehf5m4O69Gg== Date: Mon, 9 Apr 2018 00:19:02 +0000 Message-ID: <20180409001637.162453-168-alexander.levin@microsoft.com> References: <20180409001637.162453-1-alexander.levin@microsoft.com> In-Reply-To: <20180409001637.162453-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;DM5PR2101MB1125;7:R0059Dmv+3uKcjzt2Iz5+KmcLmceVKhHCFkXrC7zpBcwVDAaugF5tK7ttaE8+7BWk5qosAwTlfbgObd74zeReS1fQoljGDRaGRLmP5Ye/jsjbjehVcTeLetjauTr91zKtQKWEOIlnSAZ2lygEFQOEJ3xps0Xvbh5N+NNb2boVHLkGmJMmEdQ1/CwmiVU5RRDGW3HGmmpIot1LEDFgPA3ET9RzQEi+Szr9InSk4jXFLKL7uXOLWyX/Ccx7RhCTwLB;20:7/kF4h9NzvFWxpvZZa8xt7zyRy/cvRE1e2wyoLdFfTdjcwWFDEl4210/c3Jy/tcl9z/wNIbDXJHg1pHhkAUnAZIqglOnqXDq542tIlbMHbGloktEHizjh80LJZ7ckf8l56ALmWJBEdqhrvpIVZ/EU2/OwdA+X754Xl9gJ5+XE7w= X-MS-Office365-Filtering-Correlation-Id: edd7a9fc-0457-4660-e6b4-08d59dafcb0c x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(3008032)(48565401081)(2017052603328)(7193020);SRVR:DM5PR2101MB1125; x-ms-traffictypediagnostic: DM5PR2101MB1125: 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)(3002001)(93006095)(93001095)(10201501046)(6055026)(61426038)(61427038)(6041310)(20161123560045)(20161123564045)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:DM5PR2101MB1125;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB1125; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(366004)(376002)(396003)(39380400002)(39860400002)(346002)(199004)(189003)(105586002)(7736002)(8676002)(97736004)(81166006)(59450400001)(106356001)(81156014)(305945005)(14454004)(66066001)(1076002)(102836004)(5250100002)(478600001)(2501003)(2900100001)(22452003)(72206003)(68736007)(26005)(86362001)(575784001)(8936002)(76176011)(6506007)(6116002)(6486002)(186003)(5660300001)(3660700001)(316002)(54906003)(110136005)(25786009)(2906002)(10090500001)(6512007)(3280700002)(6666003)(10290500003)(53936002)(99286004)(86612001)(3846002)(6436002)(486006)(4326008)(2616005)(11346002)(107886003)(36756003)(476003)(446003)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB1125;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: D6SlqOx6yv8pJZHD/BOelUr0hGiGuw7Txet+vD6KBg43t4Q7t6IMcYIgTRJEckAzvfz0l8RlraNOISV57Gm9ywWBaig50TC7aLYLvn/kt8cvm712nRZew0AeTS0oekbZWI7Iqld9aFe/8Qd6LVOocMakP4aF6zyeN01L0ZhY785FuXlmaz5rMcE4U5FM0tiVZ9CFa8QEAN4CgV8cci44cGJBDR9lrU9LMj11uX6eY0TOwlOAU4Z0MixwlqTkgb6D/1VperwsI2ATIpUzYRuxKbueZVBtRXrNXu5JDKFo3eAvR0OJtebc8eaJ7Z2n6IVL70p+ly3zPmR3LeMBFvlp3K+54EwrBlLLqsGBATx5aQ6CRWC1o4pjeX6hggVpo3w3eDv9edbX1iTeeUYAA26vjG9sOa5sq+Co9wbPmr0usKw= 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: edd7a9fc-0457-4660-e6b4-08d59dafcb0c X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:19:02.5804 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1125 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 effeeb4f556f..a0bed2b2004d 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -1703,6 +1703,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