aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRonnie Sahlberg <lsahlber@redhat.com>2018-02-19 20:45:21 -0500
committerSteve French <stfrench@microsoft.com>2018-04-01 21:24:40 -0400
commit262916bc69faf90104aa784d55e10760a4199594 (patch)
tree70490ac9414d0ae727ca55a22ab4d7b1531f0777
parent70e80655f58e17a2e38e577e1b4fa7a8c99619a0 (diff)
fix smb3-encryption breakage when CONFIG_DEBUG_SG=y
We can not use the standard sg_set_buf() fucntion since when CONFIG_DEBUG_SG=y this adds a check that will BUG_ON for cifs.ko when we pass it an object from the stack. Create a new wrapper smb2_sg_set_buf() which avoids doing that particular check and use it for smb3 encryption instead. Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com> Signed-off-by: Steve French <smfrench@gmail.com> CC: Stable <stable@vger.kernel.org>
-rw-r--r--fs/cifs/smb2ops.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
index eb68e2fcc500..dfd6fb02b7a3 100644
--- a/fs/cifs/smb2ops.c
+++ b/fs/cifs/smb2ops.c
@@ -2066,6 +2066,15 @@ fill_transform_hdr(struct smb2_transform_hdr *tr_hdr, struct smb_rqst *old_rq)
2066 inc_rfc1001_len(tr_hdr, orig_len); 2066 inc_rfc1001_len(tr_hdr, orig_len);
2067} 2067}
2068 2068
2069/* We can not use the normal sg_set_buf() as we will sometimes pass a
2070 * stack object as buf.
2071 */
2072static inline void smb2_sg_set_buf(struct scatterlist *sg, const void *buf,
2073 unsigned int buflen)
2074{
2075 sg_set_page(sg, virt_to_page(buf), buflen, offset_in_page(buf));
2076}
2077
2069static struct scatterlist * 2078static struct scatterlist *
2070init_sg(struct smb_rqst *rqst, u8 *sign) 2079init_sg(struct smb_rqst *rqst, u8 *sign)
2071{ 2080{
@@ -2080,16 +2089,16 @@ init_sg(struct smb_rqst *rqst, u8 *sign)
2080 return NULL; 2089 return NULL;
2081 2090
2082 sg_init_table(sg, sg_len); 2091 sg_init_table(sg, sg_len);
2083 sg_set_buf(&sg[0], rqst->rq_iov[0].iov_base + 24, assoc_data_len); 2092 smb2_sg_set_buf(&sg[0], rqst->rq_iov[0].iov_base + 24, assoc_data_len);
2084 for (i = 1; i < rqst->rq_nvec; i++) 2093 for (i = 1; i < rqst->rq_nvec; i++)
2085 sg_set_buf(&sg[i], rqst->rq_iov[i].iov_base, 2094 smb2_sg_set_buf(&sg[i], rqst->rq_iov[i].iov_base,
2086 rqst->rq_iov[i].iov_len); 2095 rqst->rq_iov[i].iov_len);
2087 for (j = 0; i < sg_len - 1; i++, j++) { 2096 for (j = 0; i < sg_len - 1; i++, j++) {
2088 unsigned int len = (j < rqst->rq_npages - 1) ? rqst->rq_pagesz 2097 unsigned int len = (j < rqst->rq_npages - 1) ? rqst->rq_pagesz
2089 : rqst->rq_tailsz; 2098 : rqst->rq_tailsz;
2090 sg_set_page(&sg[i], rqst->rq_pages[j], len, 0); 2099 sg_set_page(&sg[i], rqst->rq_pages[j], len, 0);
2091 } 2100 }
2092 sg_set_buf(&sg[sg_len - 1], sign, SMB2_SIGNATURE_SIZE); 2101 smb2_sg_set_buf(&sg[sg_len - 1], sign, SMB2_SIGNATURE_SIZE);
2093 return sg; 2102 return sg;
2094} 2103}
2095 2104