Commit fb308a6f22f7f4f3574dab6b36c4a3598e50cf05

Authored by Jeff Layton
Committed by Steve French
1 parent 97bc00b394

cifs: teach signing routines how to deal with arrays of pages in a smb_rqst

Use the smb_send_rqst helper function to kmap each page in the array
and update the hash for that chunk.

Reviewed-by: Pavel Shilovsky <pshilovsky@samba.org>
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Steve French <smfrench@gmail.com>

Showing 4 changed files with 25 additions and 1 deletions Side-by-side Diff

fs/cifs/cifsencrypt.c
... ... @@ -29,6 +29,7 @@
29 29 #include "ntlmssp.h"
30 30 #include <linux/ctype.h>
31 31 #include <linux/random.h>
  32 +#include <linux/highmem.h>
32 33  
33 34 /*
34 35 * Calculate and return the CIFS signature based on the mac key and SMB PDU.
... ... @@ -91,6 +92,16 @@
91 92 __func__);
92 93 return rc;
93 94 }
  95 + }
  96 +
  97 + /* now hash over the rq_pages array */
  98 + for (i = 0; i < rqst->rq_npages; i++) {
  99 + struct kvec p_iov;
  100 +
  101 + cifs_rqst_page_to_kvec(rqst, i, &p_iov);
  102 + crypto_shash_update(&server->secmech.sdescmd5->shash,
  103 + p_iov.iov_base, p_iov.iov_len);
  104 + kunmap(rqst->rq_pages[i]);
94 105 }
95 106  
96 107 rc = crypto_shash_final(&server->secmech.sdescmd5->shash, signature);
... ... @@ -36,6 +36,8 @@
36 36 extern void cifs_buf_release(void *);
37 37 extern struct smb_hdr *cifs_small_buf_get(void);
38 38 extern void cifs_small_buf_release(void *);
  39 +extern void cifs_rqst_page_to_kvec(struct smb_rqst *rqst, unsigned int idx,
  40 + struct kvec *iov);
39 41 extern int smb_send(struct TCP_Server_Info *, struct smb_hdr *,
40 42 unsigned int /* length */);
41 43 extern unsigned int _get_xid(void);
fs/cifs/smb2transport.c
... ... @@ -30,6 +30,7 @@
30 30 #include <linux/uaccess.h>
31 31 #include <asm/processor.h>
32 32 #include <linux/mempool.h>
  33 +#include <linux/highmem.h>
33 34 #include "smb2pdu.h"
34 35 #include "cifsglob.h"
35 36 #include "cifsproto.h"
... ... @@ -93,6 +94,16 @@
93 94 __func__);
94 95 return rc;
95 96 }
  97 + }
  98 +
  99 + /* now hash over the rq_pages array */
  100 + for (i = 0; i < rqst->rq_npages; i++) {
  101 + struct kvec p_iov;
  102 +
  103 + cifs_rqst_page_to_kvec(rqst, i, &p_iov);
  104 + crypto_shash_update(&server->secmech.sdeschmacsha256->shash,
  105 + p_iov.iov_base, p_iov.iov_len);
  106 + kunmap(rqst->rq_pages[i]);
96 107 }
97 108  
98 109 rc = crypto_shash_final(&server->secmech.sdeschmacsha256->shash,
... ... @@ -251,7 +251,7 @@
251 251 * The page will be kmapped and the address placed into iov_base. The length
252 252 * will then be adjusted according to the ptailoff.
253 253 */
254   -static void
  254 +void
255 255 cifs_rqst_page_to_kvec(struct smb_rqst *rqst, unsigned int idx,
256 256 struct kvec *iov)
257 257 {