Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp2446790imm; Sat, 23 Jun 2018 19:08:55 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJnMVJGBnNCGgbmxyE8CspvSN/LnE0F5/RvAVk0nXi1vsuLWufjchBHDF4cfw5KDEFmZVAQ X-Received: by 2002:a17:902:5588:: with SMTP id g8-v6mr7006550pli.99.1529806134955; Sat, 23 Jun 2018 19:08:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529806134; cv=none; d=google.com; s=arc-20160816; b=T8fWqQy3r7M7V5k2YH1OvCHZjaYul6ezY/kx4jYB8Ol5oCCVOs18pWAL9eZdaGrzj2 NxUYqgpm14Zb4kcPSHXpJbZxmG1/Ttzp75F5NbFqbs4MxwPEoWbYGaOlkJkYk2Vlo77U SUB4axL4BxgNBKnGqgeoF/WWrcb0M/Pm4QCR7EG+7KS6atbHJgJdhJbt3QOFVrsfI/lW CYG8uOkbUUDnFfONov3vyfmE2TWLDZm20n75lVOJdMGx9KJj/BxKOJKQS1dpcicOzMi1 MdpuIv6O+zZSbIibWTb3Le3Q+3I3+iaG3ZM6jBWTIOl4N0DIWIja3QqpO2MvFcN1l6pZ kz2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:arc-authentication-results; bh=xxTLqjzpxAk9G9LT7yFfjwG+uIpqsz723xv+BHvny84=; b=Wq8uGiB/LunRWDKa9YhUoFacUWkog4MxTq0NDCOLviRZbvZqJ9wYNwmNFYaLf4BxeL 2QHFozGpDb6raaGLYg7/LPBGT/gieP8QV/CCV6llSnNHI7pQoNyE1UD4I0Z10Wpo8N7o bnI0DUJjB78OQu7dXW7BudOwkaOFj1StnX88izPckB9G0QrKvQk30wpcuOkA/6YZgP7c wAL2jOkASJPIOx17aZ/32z8dQTWjkWI5l3rNwqC+eK1rHzo+gHw74/k+zLX0kGzcviHN JdjPHbdyxIHEqsbZkLzwbcirhMpNdR3SNhprqDbzp1ADEx4j1OBGeqcxJQMxkEi9xpOH PitQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 7-v6si1483258pgf.687.2018.06.23.19.08.40; Sat, 23 Jun 2018 19:08:54 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751949AbeFXCHM (ORCPT + 99 others); Sat, 23 Jun 2018 22:07:12 -0400 Received: from p3plsmtpa12-02.prod.phx3.secureserver.net ([68.178.252.231]:45015 "EHLO p3plsmtpa12-02.prod.phx3.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751597AbeFXCHK (ORCPT ); Sat, 23 Jun 2018 22:07:10 -0400 Received: from [192.168.0.67] ([24.218.182.144]) by :SMTPAUTH: with ESMTPSA id WuQnf8yDKJu7xWuQnfl14O; Sat, 23 Jun 2018 19:07:10 -0700 Subject: Re: [Patch v2 05/15] CIFS: Calculate the correct request length based on page offset and tail size To: longli@microsoft.com, Steve French , linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org References: <20180530194807.31657-1-longli@linuxonhyperv.com> <20180530194807.31657-6-longli@linuxonhyperv.com> From: Tom Talpey Message-ID: <183b5cd5-b12b-de08-7867-c2addf29c974@talpey.com> Date: Sat, 23 Jun 2018 22:07:10 -0400 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180530194807.31657-6-longli@linuxonhyperv.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-CMAE-Envelope: MS4wfFwHTur7dmMiHGS5K8pCdF8Ut/MxIREKvzm8azzB0ExS8/OzmBzDCUoz+WORJZ1NkKXAC7ADU81JDdVQAAxIkxA/sUV46EEtNsgXqANZ4wWgywjnhsmN IlHT2tkYAaj/AJBR8//U6w4/xM5i5BGLLRCqhab9TwhF4/CipWqEkUENoUCCcEebKchIExS+S8xWI5p3CIoILvNRvdwkU95bhPCf1A9A02yG7rT4Muq1OFkK W40okAFMWLoL3ij4Mba2WTqjfbKqcu2r6O5Ewbcz0ywvpusCsAr9iQcIuBtv/7tOVsSh8dxrok5FIAxQGP02+7Ez/BcNod8d6/CitBfB7Xuly7/HsdmQ6eho eXreT73f Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/30/2018 3:47 PM, Long Li wrote: > From: Long Li > > It's possible that the page offset is non-zero in the pages in a request, > change the function to calculate the correct data buffer length. > > Signed-off-by: Long Li > --- > fs/cifs/transport.c | 20 +++++++++++++++++--- > 1 file changed, 17 insertions(+), 3 deletions(-) > > diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c > index 927226a..d6b5523 100644 > --- a/fs/cifs/transport.c > +++ b/fs/cifs/transport.c > @@ -212,10 +212,24 @@ rqst_len(struct smb_rqst *rqst) > for (i = 0; i < rqst->rq_nvec; i++) > buflen += iov[i].iov_len; > > - /* add in the page array if there is one */ > + /* > + * Add in the page array if there is one. The caller needs to make > + * sure rq_offset and rq_tailsz are set correctly. If a buffer of > + * multiple pages ends at page boundary, rq_tailsz needs to be set to > + * PAGE_SIZE. > + */ > if (rqst->rq_npages) { > - buflen += rqst->rq_pagesz * (rqst->rq_npages - 1); > - buflen += rqst->rq_tailsz; > + if (rqst->rq_npages == 1) > + buflen += rqst->rq_tailsz; > + else { > + /* > + * If there is more than one page, calculate the > + * buffer length based on rq_offset and rq_tailsz > + */ > + buflen += rqst->rq_pagesz * (rqst->rq_npages - 1) - > + rqst->rq_offset; > + buflen += rqst->rq_tailsz; > + } Wouldn't it be simpler to keep the original code, but then just subtract the rq_offset? buflen += rqst->rq_pagesz * (rqst->rq_npages - 1); buflen += rqst->rq_tailsz; buflen -= rqst->rq_offset; It's kind of confusing as written. Also, what if it's just one page, but has a non-zero offset? Is that somehow not possible? My suggested code would take that into account, yours doesn't. Tom. > } > > return buflen; >