Received: by 10.213.65.68 with SMTP id h4csp2114741imn; Sun, 8 Apr 2018 20:05:06 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/mYPKbNV07uY4atShA5+rmbGBshyA4XKF+Q4RuQ77VCUzpn+8J/04bCyDMlaOZbIrNGGxr X-Received: by 2002:a17:902:51ce:: with SMTP id y72-v6mr36365789plh.157.1523243106898; Sun, 08 Apr 2018 20:05:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243106; cv=none; d=google.com; s=arc-20160816; b=G3otsR8NynhwA6ban+Y/fPHuq5Rz8BZEtFNPdBPrg9Bq+AyZlQEkmCPdpbKZyvTuXE o6JYd9VIr2xOIdDUnzRjNeUd/AlciZqXPE9RVKG1gvYFBvP5nUilvqUAtickGuw3bm2Q ySYcdOEQuAL+G2OSNrOWjMZrWDwFLA/tfnhVx7FBiafFn+qK5tculMujHhFwQuU85QMs gjoYtsLKH3drygibPni1YLHbw7Eq8RRzpdnUHljtiAWX+7X8KGtJd9EZbz4r+/aNMsAQ t0hO06Z5xqyRdtPATTXFxvGKhXU3+1WTz0hbCubtrvigUz/pqQdvpS3As6pKAhJvQPAR hFcQ== 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=N4PvoO+GjBTwir4TLtORb8s+rDDPLIpx2FNqjifnyFM=; b=rhG2Gkedbq5D8SscBiA4NxpXoHjRecMigzwqEWDoAoAa73Jp5ps03i1PwrFflzVR5j 6OxcOa0+oORJ6qA0USFbQDYJ3FYGfGaMcnaC9ND+y3na64w99fXEoQ+8hYmCgObp+TmL XJevLjlsUT+i8yZxl/lnOc3uF5emfWABl8Hvb/lT/Ku3my2dL4DSEeH8+Hch5Elwdqj2 UKsuBJCZs9lEzS1LaLrv25W3jWRJKRaPk8GiSnL73pn3IxfToKcWq5ebhdzV+OFeoztA GJR08ern2zm8Ov4729k8OPWjoi7QefXnpMjQOT8MtOVbwXh3CcLWW97d27w3/bEUcOIx 40Zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=l2GANd20; 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 b96-v6si13757185pli.407.2018.04.08.20.04.29; Sun, 08 Apr 2018 20:05:06 -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=l2GANd20; 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 S933170AbeDIAji (ORCPT + 99 others); Sun, 8 Apr 2018 20:39:38 -0400 Received: from mail-co1nam03on0104.outbound.protection.outlook.com ([104.47.40.104]:37663 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933113AbeDIAj1 (ORCPT ); Sun, 8 Apr 2018 20:39:27 -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=N4PvoO+GjBTwir4TLtORb8s+rDDPLIpx2FNqjifnyFM=; b=l2GANd20fGojE9Nmv08bObkc7a3T/vaI07vSI7/2o8EFJgHxAySP9KkciVry/26tsASUpoJZnpHmhlewjW2R6J1UydiIpeYqt6x1LhAvo0zC/pmS6ZCTxpunOBSqrSke9kc/bEQLrJAQZa+NR9rqzgDf7wYpUyGgmamk5AfN0zo= 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:39:22 +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:39:22 +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.4 159/162] nfsd: return RESOURCE not GARBAGE_ARGS on too many ops Thread-Topic: [PATCH AUTOSEL for 4.4 159/162] nfsd: return RESOURCE not GARBAGE_ARGS on too many ops Thread-Index: AQHTz5nh1njdyeSiV0abDaDhuizbwA== Date: Mon, 9 Apr 2018 00:29:55 +0000 Message-ID: <20180409002738.163941-159-alexander.levin@microsoft.com> References: <20180409002738.163941-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002738.163941-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:dOqbeOGtrmIxyDaXpB4bX4aAy2RfHntzH1o05KuMSPvsQzzZ8KlPLtoUVeTZt3UN6p1wRO8ERCLlv7g05u3wjBaejdmkduZoqbAirQwpPHxiVrwef9psnAPSBCmg4rLrwe4h0hNkT7ga8rEI3emKigYWPCbIojcT2YIrMnRXwB8IJIt4bAIx41xLKwcjygO3Mctz33twhlKIMz/Cbn61e4MQi+eXszDIpAaTfzEQBG488IYIAbk6TdQ6LeD+sPq9;20:MxTrgFp5Q/s+BktFm433JDwrUl+wwe5k3ocbKbvwRNWLNmWX5trl7EYxV+KC155gFOYcmy4BRQhmEMq89UwVAomcCO1/g/rQpogeg6+zhQR1OhVlezudHvVm3mggHFbGiCvHn5a+MGp9Meq9T/N9Rl3nSJPkzN89wGdlbL8BTvc= X-MS-Office365-Filtering-Correlation-Id: 46ba8a9e-a10c-4526-678c-08d59db2568e 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)(346002)(39860400002)(39380400002)(366004)(376002)(396003)(189003)(199004)(2906002)(25786009)(6512007)(10090500001)(3280700002)(10290500003)(6666003)(3660700001)(316002)(110136005)(54906003)(11346002)(107886003)(2616005)(476003)(446003)(36756003)(99286004)(86612001)(53936002)(4326008)(486006)(6436002)(3846002)(81156014)(305945005)(5250100002)(1076002)(102836004)(14454004)(66066001)(7736002)(105586002)(81166006)(59450400001)(106356001)(8676002)(97736004)(6116002)(6506007)(6486002)(5660300001)(186003)(76176011)(22452003)(72206003)(478600001)(2501003)(2900100001)(26005)(86362001)(575784001)(8936002)(68736007)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB1125;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: 1Ahh+DiZhx8XgPXaPH8rbxmLO0ao2+DkgkzRu1XFXWamYWKlZf1MQVCGZokIzBy/JHB0N7gfKrSDZIgp6u8x4NZyE27wi1cfpURbHHmGBkaQGrJ4X0s+rHSFOVWOcNYIKzr4DvwoNzEAk0RLstpopxlMTlhi6702/JN9K48MhOnkjF8J8mI9qzdJRDr9iuUnK2dTW5ht+9giUfUZOA063fzgTA1RHLVWWebBfkxJNTFVvasYBbSeSdA/vzI6N667ei2NNs2lCc9eP4m9o1/gPDHSW6pMzy85+41BUkz1QTUE2rOBOt3O4E5kebBionGhj3173BGI0UwcuPPY6I7EbZ7NHk/NjkYJ/qXzt3mMuDepYm3JniKaPy/Dc8tz/jTCdfdZMJiBhSBWMZnV104fG1QsLEoMhaigGqaeoiOgOnQ= 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: 46ba8a9e-a10c-4526-678c-08d59db2568e X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:29:55.0528 (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 bfbee8ddf978..8f35f0a15bfa 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -1627,6 +1627,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 544672b440de..5ad02bdb62a3 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -1824,8 +1824,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