Received: by 10.213.65.68 with SMTP id h4csp2114420imn; Sun, 8 Apr 2018 20:04:41 -0700 (PDT) X-Google-Smtp-Source: AIpwx482wMaomzmiVxrh0J4k1WktXRSIUV8EJsrKP7amjtvR7lHg5wMA8ldBfLpCOO2oOSj8Mo00 X-Received: by 2002:a17:902:bd91:: with SMTP id q17-v6mr35010701pls.330.1523243081154; Sun, 08 Apr 2018 20:04:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243081; cv=none; d=google.com; s=arc-20160816; b=xB6JMyeq//COWgRZ1GvnL5ldS+hh+mkgw6TzUb7PATLqtU94MEL3DBX9lY4tn3ClAu IlZeZ6W05C3fMy6wFXgvId09EQG8WhDSMQ8k0jhoSPn41usXFQPMbeK3ZUMxkaqjlBrT pWOoOKTujkXP0yUzDDqKmjRLxj6L7Xeiuj+DsAeVffAF1FwoUNfGzmlq+Yt6lIkPSUVr NczS1TE83BxIv3JXicr7Oa5JRSYTzWt5yRqbb2U5mqLG/IbuSjL8F+crQ/HrPNfyOSmR 2I2QcykdsuQkTyGToS0E5Mew4Yp728NibDzoovaLZIkX9sFhcddNWE8Qz/vL4q2rcQe7 +6vA== 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=wRODkf6K0U//ChU/JUgkZBa/CwCLy9hGHYvSWS4MhDQ=; b=NEh/gw4ec0uIXIbAvJDRSiCPjq/5wEiFzaWyIuGlSwneR5wFgzAVugO95WamZ28EoF +2bdv7p/NBvUeYZur0jT9R65ozIMIudpFUor7xjdJDS+4l2OJH6XZDdxc1msukG2yANL /aQ0/aQY8eazxsxtxFI/ETgsIml+2GQNr7+HrVYSNlDmyncu7+Fh8CVwyLZb3JM5FQl7 sGrbmLv99P/auy7heA6lQgeSX+8s0JGaBG378CXQgzc+/AOZ90pmOxQc/wr/T3u3g/24 ZhUoNJD/ZpoEzVtI37/+59NT7RLc+1ovVRLQob4BGI3+Ha8cntvyu3NQs/mxuhW8agE/ AQtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=jTldM3+p; 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 j21si12025655pfe.132.2018.04.08.20.04.04; Sun, 08 Apr 2018 20:04:41 -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=jTldM3+p; 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 S1755352AbeDIA0d (ORCPT + 98 others); Sun, 8 Apr 2018 20:26:33 -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 S1755311AbeDIA02 (ORCPT ); Sun, 8 Apr 2018 20:26:28 -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=wRODkf6K0U//ChU/JUgkZBa/CwCLy9hGHYvSWS4MhDQ=; b=jTldM3+pfGzCN8k3QagPEBihgHv128Nq9r3XRVbf2nWsKw33Oy8Vt+4eHcZfnBJEQXmEb34eqYzoPW6iafFx59PzMmWkeyHrwohd12Ba5+UPA96PZzAk4c+M9sutA1BJFpi0ghZDe62Qcy7rdfCTgLs/zs456DEPSwpGiMdeK2I= 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:17 +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:17 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Chuck Lever , "J . Bruce Fields" , Sasha Levin Subject: [PATCH AUTOSEL for 4.14 144/161] svcrdma: Fix Read chunk round-up Thread-Topic: [PATCH AUTOSEL for 4.14 144/161] svcrdma: Fix Read chunk round-up Thread-Index: AQHTz5jBUeRQL34Qi0y7faCAz3bTfA== Date: Mon, 9 Apr 2018 00:21:51 +0000 Message-ID: <20180409001936.162706-144-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:+7EecW2wwXsi4xE2wghkcUkxjEMKSCju/BI4F1DNEaP3CpuUjWMrZT5aT/RMJBKRbQSSQKAxns/0VC0TC766fvhtr/w6MfpDW5NLBBzs4l2O0gTWyOi6L95noago++8HDyLYkgxHMt6u2SjSTqQoozwmGgDkjvAkXNJ45rruAn5sQk9nbI5cMKslAC3sGAx8UwF4watDRWxVLHzM3+kaXAExX3xHbp3Snlc0E9CdcTkIMduPmvQsD3zfgnVca63u;20:WfawtLRw/FBChPPBBSsDALTYLEnADzN3P0P5gi8nS1Muqgg8/LUNIbQ/pulpUv1Ezw7TkrHWKLx9TVjqw+3lZI9F8uMwiHSBvZQoyr+CYPohJgl0Uc6U4VfDPREPHfJhOnkawgjr0+e/KdsSih8wZHcnesP89O8gVMOvdnM8Pwo= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: f81b3665-1b8e-4bab-feec-08d59db0826f 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)(158342451672863)(89211679590171)(146099531331640); 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)(575784001)(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: eFmK1UfEv1N+hbZDLtaoykJtLQ9XLy4tjYooUCaZcMCZ1+tZPAHbjqpNzWIMQ4uQiO66rd1ZBZiEsXQoIX7YGd+YQHWNK0XIqWGioFCmUZCBZR+OjJewy3yHvgbApPnIf3XOFe8TWhNeMkiTECxCjNB2GvO0nBLco7TypVk2PpWL5Z/S6LMpKhGZXDEGCuuR1ypfjmBUpMmTN4kee8eYpJjlA4T0YIEBNi2RHyqIm/ltfz6z+vQJy5vc9CXdGP9N/vRNC+py0eM4nN/8/ZJMqlh9fXqAFFeku2xsHyl1Q1Y34UWzaX5909hLz4fWZbrKS5spUGoAOlgSU/Jt3l+IIimE/BLEzwVbMRGM2RE1PN4vFXuh3u8OMWdHfXR4j2XNsZnvnmcCjANmjaPJgLVoak43QtXLyPiYl+zKPHsDIMA= 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: f81b3665-1b8e-4bab-feec-08d59db0826f X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:21:51.0811 (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: Chuck Lever [ Upstream commit 175e03101d36c3034f3c80038d4c28838351a7f2 ] A single NFSv4 WRITE compound can often have three operations: PUTFH, WRITE, then GETATTR. When the WRITE payload is sent in a Read chunk, the client places the GETATTR in the inline part of the RPC/RDMA message, just after the WRITE operation (sans payload). The position value in the Read chunk enables the receiver to insert the Read chunk at the correct place in the received XDR stream; that is between the WRITE and GETATTR. According to RFC 8166, an NFS/RDMA client does not have to add XDR round-up to the Read chunk that carries the WRITE payload. The receiver adds XDR round-up padding if it is absent and the receiver's XDR decoder requires it to be present. Commit 193bcb7b3719 ("svcrdma: Populate tail iovec when receiving") attempted to add support for receiving such a compound so that just the WRITE payload appears in rq_arg's page list, and the trailing GETATTR is placed in rq_arg's tail iovec. (TCP just strings the whole compound into the head iovec and page list, without regard to the alignment of the WRITE payload). The server transport logic also had to accommodate the optional XDR round-up of the Read chunk, which it did simply by lengthening the tail iovec when round-up was needed. This approach is adequate for the NFSv2 and NFSv3 WRITE decoders. Unfortunately it is not sufficient for nfsd4_decode_write. When the Read chunk length is a couple of bytes less than PAGE_SIZE, the computation at the end of nfsd4_decode_write allows argp->pagelen to go negative, which breaks the logic in read_buf that looks for the tail iovec. The result is that a WRITE operation whose payload length is just less than a multiple of a page succeeds, but the subsequent GETATTR in the same compound fails with NFS4ERR_OP_ILLEGAL because the XDR decoder can't find it. Clients ignore the error, but they must update their attribute cache via a separate round trip. As nfsd4_decode_write appears to expect the payload itself to always have appropriate XDR round-up, have svc_rdma_build_normal_read_chunk add the Read chunk XDR round-up to the page_len rather than lengthening the tail iovec. Reported-by: Olga Kornievskaia Fixes: 193bcb7b3719 ("svcrdma: Populate tail iovec when receiving") Signed-off-by: Chuck Lever Tested-by: Olga Kornievskaia Signed-off-by: J. Bruce Fields Signed-off-by: Sasha Levin --- net/sunrpc/xprtrdma/svc_rdma_rw.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/net/sunrpc/xprtrdma/svc_rdma_rw.c b/net/sunrpc/xprtrdma/svc_rd= ma_rw.c index 9bd04549a1ad..12b9a7e0b6d2 100644 --- a/net/sunrpc/xprtrdma/svc_rdma_rw.c +++ b/net/sunrpc/xprtrdma/svc_rdma_rw.c @@ -727,12 +727,16 @@ static int svc_rdma_build_normal_read_chunk(struct sv= c_rqst *rqstp, head->arg.head[0].iov_len - info->ri_position; head->arg.head[0].iov_len =3D info->ri_position; =20 - /* Read chunk may need XDR roundup (see RFC 5666, s. 3.7). + /* Read chunk may need XDR roundup (see RFC 8166, s. 3.4.5.2). * - * NFSv2/3 write decoders need the length of the tail to - * contain the size of the roundup padding. + * If the client already rounded up the chunk length, the + * length does not change. Otherwise, the length of the page + * list is increased to include XDR round-up. + * + * Currently these chunks always start at page offset 0, + * thus the rounded-up length never crosses a page boundary. */ - head->arg.tail[0].iov_len +=3D 4 - (info->ri_chunklen & 3); + info->ri_chunklen =3D XDR_QUADLEN(info->ri_chunklen) << 2; =20 head->arg.page_len =3D info->ri_chunklen; head->arg.len +=3D info->ri_chunklen; --=20 2.15.1