diff options
author | Pavel Shilovsky <piastry@etersoft.ru> | 2012-03-23 14:28:02 -0400 |
---|---|---|
committer | Jeff Layton <jlayton@redhat.com> | 2012-03-23 14:28:02 -0400 |
commit | d4e4854fd1c85ac8ba4d6de39703e07704754b85 (patch) | |
tree | 96cbc43691d2bbef4a03087a3d1ac8c26ffff827 /fs/cifs | |
parent | 792af7b05b8a78def080ec757a4d4420b9fd0cc2 (diff) |
CIFS: Separate protocol-specific code from demultiplex code
Signed-off-by: Pavel Shilovsky <piastry@etersoft.ru>
Diffstat (limited to 'fs/cifs')
-rw-r--r-- | fs/cifs/cifs_debug.c | 5 | ||||
-rw-r--r-- | fs/cifs/cifs_debug.h | 2 | ||||
-rw-r--r-- | fs/cifs/cifsglob.h | 2 | ||||
-rw-r--r-- | fs/cifs/cifsproto.h | 5 | ||||
-rw-r--r-- | fs/cifs/connect.c | 78 | ||||
-rw-r--r-- | fs/cifs/misc.c | 7 | ||||
-rw-r--r-- | fs/cifs/transport.c | 4 |
7 files changed, 56 insertions, 47 deletions
diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c index 573b899b5a5d..bcd0db783196 100644 --- a/fs/cifs/cifs_debug.c +++ b/fs/cifs/cifs_debug.c | |||
@@ -58,15 +58,16 @@ cifs_dump_mem(char *label, void *data, int length) | |||
58 | } | 58 | } |
59 | 59 | ||
60 | #ifdef CONFIG_CIFS_DEBUG2 | 60 | #ifdef CONFIG_CIFS_DEBUG2 |
61 | void cifs_dump_detail(struct smb_hdr *smb) | 61 | void cifs_dump_detail(void *buf) |
62 | { | 62 | { |
63 | struct smb_hdr *smb = (struct smb_hdr *)buf; | ||
64 | |||
63 | cERROR(1, "Cmd: %d Err: 0x%x Flags: 0x%x Flgs2: 0x%x Mid: %d Pid: %d", | 65 | cERROR(1, "Cmd: %d Err: 0x%x Flags: 0x%x Flgs2: 0x%x Mid: %d Pid: %d", |
64 | smb->Command, smb->Status.CifsError, | 66 | smb->Command, smb->Status.CifsError, |
65 | smb->Flags, smb->Flags2, smb->Mid, smb->Pid); | 67 | smb->Flags, smb->Flags2, smb->Mid, smb->Pid); |
66 | cERROR(1, "smb buf %p len %d", smb, smbCalcSize(smb)); | 68 | cERROR(1, "smb buf %p len %d", smb, smbCalcSize(smb)); |
67 | } | 69 | } |
68 | 70 | ||
69 | |||
70 | void cifs_dump_mids(struct TCP_Server_Info *server) | 71 | void cifs_dump_mids(struct TCP_Server_Info *server) |
71 | { | 72 | { |
72 | struct list_head *tmp; | 73 | struct list_head *tmp; |
diff --git a/fs/cifs/cifs_debug.h b/fs/cifs/cifs_debug.h index 0a234c1db947..566e0ae8dc2c 100644 --- a/fs/cifs/cifs_debug.h +++ b/fs/cifs/cifs_debug.h | |||
@@ -26,7 +26,7 @@ | |||
26 | void cifs_dump_mem(char *label, void *data, int length); | 26 | void cifs_dump_mem(char *label, void *data, int length); |
27 | #ifdef CONFIG_CIFS_DEBUG2 | 27 | #ifdef CONFIG_CIFS_DEBUG2 |
28 | #define DBG2 2 | 28 | #define DBG2 2 |
29 | void cifs_dump_detail(struct smb_hdr *); | 29 | void cifs_dump_detail(void *); |
30 | void cifs_dump_mids(struct TCP_Server_Info *); | 30 | void cifs_dump_mids(struct TCP_Server_Info *); |
31 | #else | 31 | #else |
32 | #define DBG2 0 | 32 | #define DBG2 0 |
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index c3c7d7c46220..34a897e3d225 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h | |||
@@ -730,7 +730,7 @@ struct mid_q_entry { | |||
730 | mid_receive_t *receive; /* call receive callback */ | 730 | mid_receive_t *receive; /* call receive callback */ |
731 | mid_callback_t *callback; /* call completion callback */ | 731 | mid_callback_t *callback; /* call completion callback */ |
732 | void *callback_data; /* general purpose pointer for callback */ | 732 | void *callback_data; /* general purpose pointer for callback */ |
733 | struct smb_hdr *resp_buf; /* pointer to received SMB header */ | 733 | void *resp_buf; /* pointer to received SMB header */ |
734 | int midState; /* wish this were enum but can not pass to wait_event */ | 734 | int midState; /* wish this were enum but can not pass to wait_event */ |
735 | __u8 command; /* smb command code */ | 735 | __u8 command; /* smb command code */ |
736 | bool largeBuf:1; /* if valid response, is pointer to large buf */ | 736 | bool largeBuf:1; /* if valid response, is pointer to large buf */ |
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h index 5f2f266c42a4..70124ae77aa8 100644 --- a/fs/cifs/cifsproto.h +++ b/fs/cifs/cifsproto.h | |||
@@ -91,9 +91,8 @@ extern int SendReceiveBlockingLock(const unsigned int xid, | |||
91 | extern void cifs_add_credits(struct TCP_Server_Info *server, | 91 | extern void cifs_add_credits(struct TCP_Server_Info *server, |
92 | const unsigned int add); | 92 | const unsigned int add); |
93 | extern void cifs_set_credits(struct TCP_Server_Info *server, const int val); | 93 | extern void cifs_set_credits(struct TCP_Server_Info *server, const int val); |
94 | extern int checkSMB(struct smb_hdr *smb, __u16 mid, unsigned int length); | 94 | extern int checkSMB(char *buf, unsigned int length); |
95 | extern bool is_valid_oplock_break(struct smb_hdr *smb, | 95 | extern bool is_valid_oplock_break(char *, struct TCP_Server_Info *); |
96 | struct TCP_Server_Info *); | ||
97 | extern bool backup_cred(struct cifs_sb_info *); | 96 | extern bool backup_cred(struct cifs_sb_info *); |
98 | extern bool is_size_safe_to_change(struct cifsInodeInfo *, __u64 eof); | 97 | extern bool is_size_safe_to_change(struct cifsInodeInfo *, __u64 eof); |
99 | extern void cifs_update_eof(struct cifsInodeInfo *cifsi, loff_t offset, | 98 | extern void cifs_update_eof(struct cifsInodeInfo *cifsi, loff_t offset, |
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 5560e1d5e54b..cb6e757feb52 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c | |||
@@ -183,8 +183,9 @@ cifs_reconnect(struct TCP_Server_Info *server) | |||
183 | -EINVAL = invalid transact2 | 183 | -EINVAL = invalid transact2 |
184 | 184 | ||
185 | */ | 185 | */ |
186 | static int check2ndT2(struct smb_hdr *pSMB) | 186 | static int check2ndT2(char *buf) |
187 | { | 187 | { |
188 | struct smb_hdr *pSMB = (struct smb_hdr *)buf; | ||
188 | struct smb_t2_rsp *pSMBt; | 189 | struct smb_t2_rsp *pSMBt; |
189 | int remaining; | 190 | int remaining; |
190 | __u16 total_data_size, data_in_this_rsp; | 191 | __u16 total_data_size, data_in_this_rsp; |
@@ -224,10 +225,10 @@ static int check2ndT2(struct smb_hdr *pSMB) | |||
224 | return remaining; | 225 | return remaining; |
225 | } | 226 | } |
226 | 227 | ||
227 | static int coalesce_t2(struct smb_hdr *psecond, struct smb_hdr *pTargetSMB) | 228 | static int coalesce_t2(char *second_buf, struct smb_hdr *target_hdr) |
228 | { | 229 | { |
229 | struct smb_t2_rsp *pSMBs = (struct smb_t2_rsp *)psecond; | 230 | struct smb_t2_rsp *pSMBs = (struct smb_t2_rsp *)second_buf; |
230 | struct smb_t2_rsp *pSMBt = (struct smb_t2_rsp *)pTargetSMB; | 231 | struct smb_t2_rsp *pSMBt = (struct smb_t2_rsp *)target_hdr; |
231 | char *data_area_of_tgt; | 232 | char *data_area_of_tgt; |
232 | char *data_area_of_src; | 233 | char *data_area_of_src; |
233 | int remaining; | 234 | int remaining; |
@@ -280,23 +281,23 @@ static int coalesce_t2(struct smb_hdr *psecond, struct smb_hdr *pTargetSMB) | |||
280 | put_unaligned_le16(total_in_tgt, &pSMBt->t2_rsp.DataCount); | 281 | put_unaligned_le16(total_in_tgt, &pSMBt->t2_rsp.DataCount); |
281 | 282 | ||
282 | /* fix up the BCC */ | 283 | /* fix up the BCC */ |
283 | byte_count = get_bcc(pTargetSMB); | 284 | byte_count = get_bcc(target_hdr); |
284 | byte_count += total_in_src; | 285 | byte_count += total_in_src; |
285 | /* is the result too big for the field? */ | 286 | /* is the result too big for the field? */ |
286 | if (byte_count > USHRT_MAX) { | 287 | if (byte_count > USHRT_MAX) { |
287 | cFYI(1, "coalesced BCC too large (%u)", byte_count); | 288 | cFYI(1, "coalesced BCC too large (%u)", byte_count); |
288 | return -EPROTO; | 289 | return -EPROTO; |
289 | } | 290 | } |
290 | put_bcc(byte_count, pTargetSMB); | 291 | put_bcc(byte_count, target_hdr); |
291 | 292 | ||
292 | byte_count = be32_to_cpu(pTargetSMB->smb_buf_length); | 293 | byte_count = be32_to_cpu(target_hdr->smb_buf_length); |
293 | byte_count += total_in_src; | 294 | byte_count += total_in_src; |
294 | /* don't allow buffer to overflow */ | 295 | /* don't allow buffer to overflow */ |
295 | if (byte_count > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) { | 296 | if (byte_count > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) { |
296 | cFYI(1, "coalesced BCC exceeds buffer size (%u)", byte_count); | 297 | cFYI(1, "coalesced BCC exceeds buffer size (%u)", byte_count); |
297 | return -ENOBUFS; | 298 | return -ENOBUFS; |
298 | } | 299 | } |
299 | pTargetSMB->smb_buf_length = cpu_to_be32(byte_count); | 300 | target_hdr->smb_buf_length = cpu_to_be32(byte_count); |
300 | 301 | ||
301 | /* copy second buffer into end of first buffer */ | 302 | /* copy second buffer into end of first buffer */ |
302 | memcpy(data_area_of_tgt, data_area_of_src, total_in_src); | 303 | memcpy(data_area_of_tgt, data_area_of_src, total_in_src); |
@@ -337,6 +338,18 @@ requeue_echo: | |||
337 | queue_delayed_work(system_nrt_wq, &server->echo, SMB_ECHO_INTERVAL); | 338 | queue_delayed_work(system_nrt_wq, &server->echo, SMB_ECHO_INTERVAL); |
338 | } | 339 | } |
339 | 340 | ||
341 | static inline size_t | ||
342 | header_size(void) | ||
343 | { | ||
344 | return sizeof(struct smb_hdr); | ||
345 | } | ||
346 | |||
347 | static inline size_t | ||
348 | max_header_size(void) | ||
349 | { | ||
350 | return MAX_CIFS_HDR_SIZE; | ||
351 | } | ||
352 | |||
340 | static bool | 353 | static bool |
341 | allocate_buffers(struct TCP_Server_Info *server) | 354 | allocate_buffers(struct TCP_Server_Info *server) |
342 | { | 355 | { |
@@ -350,7 +363,7 @@ allocate_buffers(struct TCP_Server_Info *server) | |||
350 | } | 363 | } |
351 | } else if (server->large_buf) { | 364 | } else if (server->large_buf) { |
352 | /* we are reusing a dirty large buf, clear its start */ | 365 | /* we are reusing a dirty large buf, clear its start */ |
353 | memset(server->bigbuf, 0, sizeof(struct smb_hdr)); | 366 | memset(server->bigbuf, 0, header_size()); |
354 | } | 367 | } |
355 | 368 | ||
356 | if (!server->smallbuf) { | 369 | if (!server->smallbuf) { |
@@ -364,7 +377,7 @@ allocate_buffers(struct TCP_Server_Info *server) | |||
364 | /* beginning of smb buffer is cleared in our buf_get */ | 377 | /* beginning of smb buffer is cleared in our buf_get */ |
365 | } else { | 378 | } else { |
366 | /* if existing small buf clear beginning */ | 379 | /* if existing small buf clear beginning */ |
367 | memset(server->smallbuf, 0, sizeof(struct smb_hdr)); | 380 | memset(server->smallbuf, 0, header_size()); |
368 | } | 381 | } |
369 | 382 | ||
370 | return true; | 383 | return true; |
@@ -566,8 +579,9 @@ is_smb_response(struct TCP_Server_Info *server, unsigned char type) | |||
566 | } | 579 | } |
567 | 580 | ||
568 | static struct mid_q_entry * | 581 | static struct mid_q_entry * |
569 | find_mid(struct TCP_Server_Info *server, struct smb_hdr *buf) | 582 | find_mid(struct TCP_Server_Info *server, char *buffer) |
570 | { | 583 | { |
584 | struct smb_hdr *buf = (struct smb_hdr *)buffer; | ||
571 | struct mid_q_entry *mid; | 585 | struct mid_q_entry *mid; |
572 | 586 | ||
573 | spin_lock(&GlobalMid_Lock); | 587 | spin_lock(&GlobalMid_Lock); |
@@ -600,7 +614,7 @@ dequeue_mid(struct mid_q_entry *mid, bool malformed) | |||
600 | 614 | ||
601 | static void | 615 | static void |
602 | handle_mid(struct mid_q_entry *mid, struct TCP_Server_Info *server, | 616 | handle_mid(struct mid_q_entry *mid, struct TCP_Server_Info *server, |
603 | struct smb_hdr *buf, int malformed) | 617 | char *buf, int malformed) |
604 | { | 618 | { |
605 | if (malformed == 0 && check2ndT2(buf) > 0) { | 619 | if (malformed == 0 && check2ndT2(buf) > 0) { |
606 | mid->multiRsp = true; | 620 | mid->multiRsp = true; |
@@ -731,11 +745,10 @@ standard_receive3(struct TCP_Server_Info *server, struct mid_q_entry *mid) | |||
731 | { | 745 | { |
732 | int length; | 746 | int length; |
733 | char *buf = server->smallbuf; | 747 | char *buf = server->smallbuf; |
734 | struct smb_hdr *smb_buffer = (struct smb_hdr *)buf; | 748 | unsigned int pdu_length = get_rfc1002_length(buf); |
735 | unsigned int pdu_length = be32_to_cpu(smb_buffer->smb_buf_length); | ||
736 | 749 | ||
737 | /* make sure this will fit in a large buffer */ | 750 | /* make sure this will fit in a large buffer */ |
738 | if (pdu_length > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) { | 751 | if (pdu_length > CIFSMaxBufSize + max_header_size() - 4) { |
739 | cERROR(1, "SMB response too long (%u bytes)", | 752 | cERROR(1, "SMB response too long (%u bytes)", |
740 | pdu_length); | 753 | pdu_length); |
741 | cifs_reconnect(server); | 754 | cifs_reconnect(server); |
@@ -746,20 +759,18 @@ standard_receive3(struct TCP_Server_Info *server, struct mid_q_entry *mid) | |||
746 | /* switch to large buffer if too big for a small one */ | 759 | /* switch to large buffer if too big for a small one */ |
747 | if (pdu_length > MAX_CIFS_SMALL_BUFFER_SIZE - 4) { | 760 | if (pdu_length > MAX_CIFS_SMALL_BUFFER_SIZE - 4) { |
748 | server->large_buf = true; | 761 | server->large_buf = true; |
749 | memcpy(server->bigbuf, server->smallbuf, server->total_read); | 762 | memcpy(server->bigbuf, buf, server->total_read); |
750 | buf = server->bigbuf; | 763 | buf = server->bigbuf; |
751 | smb_buffer = (struct smb_hdr *)buf; | ||
752 | } | 764 | } |
753 | 765 | ||
754 | /* now read the rest */ | 766 | /* now read the rest */ |
755 | length = cifs_read_from_socket(server, | 767 | length = cifs_read_from_socket(server, buf + header_size() - 1, |
756 | buf + sizeof(struct smb_hdr) - 1, | 768 | pdu_length - header_size() + 1 + 4); |
757 | pdu_length - sizeof(struct smb_hdr) + 1 + 4); | ||
758 | if (length < 0) | 769 | if (length < 0) |
759 | return length; | 770 | return length; |
760 | server->total_read += length; | 771 | server->total_read += length; |
761 | 772 | ||
762 | dump_smb(smb_buffer, server->total_read); | 773 | dump_smb(buf, server->total_read); |
763 | 774 | ||
764 | /* | 775 | /* |
765 | * We know that we received enough to get to the MID as we | 776 | * We know that we received enough to get to the MID as we |
@@ -770,7 +781,7 @@ standard_receive3(struct TCP_Server_Info *server, struct mid_q_entry *mid) | |||
770 | * 48 bytes is enough to display the header and a little bit | 781 | * 48 bytes is enough to display the header and a little bit |
771 | * into the payload for debugging purposes. | 782 | * into the payload for debugging purposes. |
772 | */ | 783 | */ |
773 | length = checkSMB(smb_buffer, smb_buffer->Mid, server->total_read); | 784 | length = checkSMB(buf, server->total_read); |
774 | if (length != 0) | 785 | if (length != 0) |
775 | cifs_dump_mem("Bad SMB: ", buf, | 786 | cifs_dump_mem("Bad SMB: ", buf, |
776 | min_t(unsigned int, server->total_read, 48)); | 787 | min_t(unsigned int, server->total_read, 48)); |
@@ -778,7 +789,7 @@ standard_receive3(struct TCP_Server_Info *server, struct mid_q_entry *mid) | |||
778 | if (!mid) | 789 | if (!mid) |
779 | return length; | 790 | return length; |
780 | 791 | ||
781 | handle_mid(mid, server, smb_buffer, length); | 792 | handle_mid(mid, server, buf, length); |
782 | return 0; | 793 | return 0; |
783 | } | 794 | } |
784 | 795 | ||
@@ -789,7 +800,6 @@ cifs_demultiplex_thread(void *p) | |||
789 | struct TCP_Server_Info *server = p; | 800 | struct TCP_Server_Info *server = p; |
790 | unsigned int pdu_length; | 801 | unsigned int pdu_length; |
791 | char *buf = NULL; | 802 | char *buf = NULL; |
792 | struct smb_hdr *smb_buffer = NULL; | ||
793 | struct task_struct *task_to_wake = NULL; | 803 | struct task_struct *task_to_wake = NULL; |
794 | struct mid_q_entry *mid_entry; | 804 | struct mid_q_entry *mid_entry; |
795 | 805 | ||
@@ -810,7 +820,6 @@ cifs_demultiplex_thread(void *p) | |||
810 | continue; | 820 | continue; |
811 | 821 | ||
812 | server->large_buf = false; | 822 | server->large_buf = false; |
813 | smb_buffer = (struct smb_hdr *)server->smallbuf; | ||
814 | buf = server->smallbuf; | 823 | buf = server->smallbuf; |
815 | pdu_length = 4; /* enough to get RFC1001 header */ | 824 | pdu_length = 4; /* enough to get RFC1001 header */ |
816 | 825 | ||
@@ -823,14 +832,14 @@ cifs_demultiplex_thread(void *p) | |||
823 | * The right amount was read from socket - 4 bytes, | 832 | * The right amount was read from socket - 4 bytes, |
824 | * so we can now interpret the length field. | 833 | * so we can now interpret the length field. |
825 | */ | 834 | */ |
826 | pdu_length = be32_to_cpu(smb_buffer->smb_buf_length); | 835 | pdu_length = get_rfc1002_length(buf); |
827 | 836 | ||
828 | cFYI(1, "RFC1002 header 0x%x", pdu_length); | 837 | cFYI(1, "RFC1002 header 0x%x", pdu_length); |
829 | if (!is_smb_response(server, buf[0])) | 838 | if (!is_smb_response(server, buf[0])) |
830 | continue; | 839 | continue; |
831 | 840 | ||
832 | /* make sure we have enough to get to the MID */ | 841 | /* make sure we have enough to get to the MID */ |
833 | if (pdu_length < sizeof(struct smb_hdr) - 1 - 4) { | 842 | if (pdu_length < header_size() - 1 - 4) { |
834 | cERROR(1, "SMB response too short (%u bytes)", | 843 | cERROR(1, "SMB response too short (%u bytes)", |
835 | pdu_length); | 844 | pdu_length); |
836 | cifs_reconnect(server); | 845 | cifs_reconnect(server); |
@@ -840,12 +849,12 @@ cifs_demultiplex_thread(void *p) | |||
840 | 849 | ||
841 | /* read down to the MID */ | 850 | /* read down to the MID */ |
842 | length = cifs_read_from_socket(server, buf + 4, | 851 | length = cifs_read_from_socket(server, buf + 4, |
843 | sizeof(struct smb_hdr) - 1 - 4); | 852 | header_size() - 1 - 4); |
844 | if (length < 0) | 853 | if (length < 0) |
845 | continue; | 854 | continue; |
846 | server->total_read += length; | 855 | server->total_read += length; |
847 | 856 | ||
848 | mid_entry = find_mid(server, smb_buffer); | 857 | mid_entry = find_mid(server, buf); |
849 | 858 | ||
850 | if (!mid_entry || !mid_entry->receive) | 859 | if (!mid_entry || !mid_entry->receive) |
851 | length = standard_receive3(server, mid_entry); | 860 | length = standard_receive3(server, mid_entry); |
@@ -855,22 +864,19 @@ cifs_demultiplex_thread(void *p) | |||
855 | if (length < 0) | 864 | if (length < 0) |
856 | continue; | 865 | continue; |
857 | 866 | ||
858 | if (server->large_buf) { | 867 | if (server->large_buf) |
859 | buf = server->bigbuf; | 868 | buf = server->bigbuf; |
860 | smb_buffer = (struct smb_hdr *)buf; | ||
861 | } | ||
862 | 869 | ||
863 | server->lstrp = jiffies; | 870 | server->lstrp = jiffies; |
864 | if (mid_entry != NULL) { | 871 | if (mid_entry != NULL) { |
865 | if (!mid_entry->multiRsp || mid_entry->multiEnd) | 872 | if (!mid_entry->multiRsp || mid_entry->multiEnd) |
866 | mid_entry->callback(mid_entry); | 873 | mid_entry->callback(mid_entry); |
867 | } else if (!is_valid_oplock_break(smb_buffer, server)) { | 874 | } else if (!is_valid_oplock_break(buf, server)) { |
868 | cERROR(1, "No task to wake, unknown frame received! " | 875 | cERROR(1, "No task to wake, unknown frame received! " |
869 | "NumMids %d", atomic_read(&midCount)); | 876 | "NumMids %d", atomic_read(&midCount)); |
870 | cifs_dump_mem("Received Data is: ", buf, | 877 | cifs_dump_mem("Received Data is: ", buf, header_size()); |
871 | sizeof(struct smb_hdr)); | ||
872 | #ifdef CONFIG_CIFS_DEBUG2 | 878 | #ifdef CONFIG_CIFS_DEBUG2 |
873 | cifs_dump_detail(smb_buffer); | 879 | cifs_dump_detail(buf); |
874 | cifs_dump_mids(server); | 880 | cifs_dump_mids(server); |
875 | #endif /* CIFS_DEBUG2 */ | 881 | #endif /* CIFS_DEBUG2 */ |
876 | 882 | ||
diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c index e88601fc6f22..dc61dff2c42a 100644 --- a/fs/cifs/misc.c +++ b/fs/cifs/misc.c | |||
@@ -420,8 +420,10 @@ check_smb_hdr(struct smb_hdr *smb, __u16 mid) | |||
420 | } | 420 | } |
421 | 421 | ||
422 | int | 422 | int |
423 | checkSMB(struct smb_hdr *smb, __u16 mid, unsigned int total_read) | 423 | checkSMB(char *buf, unsigned int total_read) |
424 | { | 424 | { |
425 | struct smb_hdr *smb = (struct smb_hdr *)buf; | ||
426 | __u16 mid = smb->Mid; | ||
425 | __u32 rfclen = be32_to_cpu(smb->smb_buf_length); | 427 | __u32 rfclen = be32_to_cpu(smb->smb_buf_length); |
426 | __u32 clc_len; /* calculated length */ | 428 | __u32 clc_len; /* calculated length */ |
427 | cFYI(0, "checkSMB Length: 0x%x, smb_buf_length: 0x%x", | 429 | cFYI(0, "checkSMB Length: 0x%x, smb_buf_length: 0x%x", |
@@ -502,8 +504,9 @@ checkSMB(struct smb_hdr *smb, __u16 mid, unsigned int total_read) | |||
502 | } | 504 | } |
503 | 505 | ||
504 | bool | 506 | bool |
505 | is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv) | 507 | is_valid_oplock_break(char *buffer, struct TCP_Server_Info *srv) |
506 | { | 508 | { |
509 | struct smb_hdr *buf = (struct smb_hdr *)buffer; | ||
507 | struct smb_com_lock_req *pSMB = (struct smb_com_lock_req *)buf; | 510 | struct smb_com_lock_req *pSMB = (struct smb_com_lock_req *)buf; |
508 | struct list_head *tmp, *tmp1, *tmp2; | 511 | struct list_head *tmp, *tmp1, *tmp2; |
509 | struct cifs_ses *ses; | 512 | struct cifs_ses *ses; |
diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c index 3bb447d07a1d..66b4edec0e8e 100644 --- a/fs/cifs/transport.c +++ b/fs/cifs/transport.c | |||
@@ -778,7 +778,7 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses, | |||
778 | goto out; | 778 | goto out; |
779 | } | 779 | } |
780 | 780 | ||
781 | *pbytes_returned = be32_to_cpu(midQ->resp_buf->smb_buf_length); | 781 | *pbytes_returned = get_rfc1002_length(midQ->resp_buf); |
782 | memcpy(out_buf, midQ->resp_buf, *pbytes_returned + 4); | 782 | memcpy(out_buf, midQ->resp_buf, *pbytes_returned + 4); |
783 | rc = cifs_check_receive(midQ, ses->server, 0); | 783 | rc = cifs_check_receive(midQ, ses->server, 0); |
784 | out: | 784 | out: |
@@ -945,7 +945,7 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon, | |||
945 | goto out; | 945 | goto out; |
946 | } | 946 | } |
947 | 947 | ||
948 | *pbytes_returned = be32_to_cpu(midQ->resp_buf->smb_buf_length); | 948 | *pbytes_returned = get_rfc1002_length(midQ->resp_buf); |
949 | memcpy(out_buf, midQ->resp_buf, *pbytes_returned + 4); | 949 | memcpy(out_buf, midQ->resp_buf, *pbytes_returned + 4); |
950 | rc = cifs_check_receive(midQ, ses->server, 0); | 950 | rc = cifs_check_receive(midQ, ses->server, 0); |
951 | out: | 951 | out: |