]> Pileus Git - ~andy/linux/commitdiff
cifs: teach signing routines how to deal with arrays of pages in a smb_rqst
authorJeff Layton <jlayton@redhat.com>
Tue, 18 Sep 2012 23:20:35 +0000 (16:20 -0700)
committerSteve French <smfrench@gmail.com>
Tue, 25 Sep 2012 02:46:31 +0000 (21:46 -0500)
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>
fs/cifs/cifsencrypt.c
fs/cifs/cifsproto.h
fs/cifs/smb2transport.c
fs/cifs/transport.c

index af520522ef20e1acb47999a4200b50d6b3dfffbf..652f5051be093c5080878ddcabd30879fcd695ee 100644 (file)
@@ -29,6 +29,7 @@
 #include "ntlmssp.h"
 #include <linux/ctype.h>
 #include <linux/random.h>
+#include <linux/highmem.h>
 
 /*
  * Calculate and return the CIFS signature based on the mac key and SMB PDU.
@@ -93,6 +94,16 @@ static int cifs_calc_signature(struct smb_rqst *rqst,
                }
        }
 
+       /* now hash over the rq_pages array */
+       for (i = 0; i < rqst->rq_npages; i++) {
+               struct kvec p_iov;
+
+               cifs_rqst_page_to_kvec(rqst, i, &p_iov);
+               crypto_shash_update(&server->secmech.sdescmd5->shash,
+                                       p_iov.iov_base, p_iov.iov_len);
+               kunmap(rqst->rq_pages[i]);
+       }
+
        rc = crypto_shash_final(&server->secmech.sdescmd5->shash, signature);
        if (rc)
                cERROR(1, "%s: Could not generate md5 hash", __func__);
index 8e071a5a7da4da17b34f196080663c63ab051f4e..e97a1843ab983ef01e59eae2de9ebf309d4c4d72 100644 (file)
@@ -36,6 +36,8 @@ extern struct smb_hdr *cifs_buf_get(void);
 extern void cifs_buf_release(void *);
 extern struct smb_hdr *cifs_small_buf_get(void);
 extern void cifs_small_buf_release(void *);
+extern void cifs_rqst_page_to_kvec(struct smb_rqst *rqst, unsigned int idx,
+                                       struct kvec *iov);
 extern int smb_send(struct TCP_Server_Info *, struct smb_hdr *,
                        unsigned int /* length */);
 extern unsigned int _get_xid(void);
index 1850d9ec3c9042f355bc0f6069079f65c1854e1b..9ca4bcfb34c6e7effb7a4ec5d9dffb4512697cfc 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/uaccess.h>
 #include <asm/processor.h>
 #include <linux/mempool.h>
+#include <linux/highmem.h>
 #include "smb2pdu.h"
 #include "cifsglob.h"
 #include "cifsproto.h"
@@ -95,6 +96,16 @@ smb2_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server)
                }
        }
 
+       /* now hash over the rq_pages array */
+       for (i = 0; i < rqst->rq_npages; i++) {
+               struct kvec p_iov;
+
+               cifs_rqst_page_to_kvec(rqst, i, &p_iov);
+               crypto_shash_update(&server->secmech.sdeschmacsha256->shash,
+                                       p_iov.iov_base, p_iov.iov_len);
+               kunmap(rqst->rq_pages[i]);
+       }
+
        rc = crypto_shash_final(&server->secmech.sdeschmacsha256->shash,
                                sigptr);
        if (rc)
index 381dbb778478ed27094aae16953eb6d437360307..b6097344cd5bb18fdb0682c35ced87987eb4fda9 100644 (file)
@@ -251,7 +251,7 @@ smb_send_kvec(struct TCP_Server_Info *server, struct kvec *iov, size_t n_vec,
  * The page will be kmapped and the address placed into iov_base. The length
  * will then be adjusted according to the ptailoff.
  */
-static void
+void
 cifs_rqst_page_to_kvec(struct smb_rqst *rqst, unsigned int idx,
                        struct kvec *iov)
 {