summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLong Li <longli@microsoft.com>2018-05-30 12:47:57 -0700
committerSteve French <stfrench@microsoft.com>2018-06-05 17:39:46 -0500
commitc06a0f2dff704d9f734ff0d3d4812ccfc46ed8d0 (patch)
tree40b00a77af1f00b706e2e515d3a781c08396e5c7
parentee25c6dd7b05113783ce1f4fab6b30fc00d29b8d (diff)
downloadlinux-c06a0f2dff704d9f734ff0d3d4812ccfc46ed8d0.tar.bz2
CIFS: Calculate the correct request length based on page offset and tail size
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 <longli@microsoft.com> Signed-off-by: Steve French <stfrench@microsoft.com>
-rw-r--r--fs/cifs/transport.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c
index e7254e386b79..d6cff1e5afc6 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;
+ }
}
return buflen;