diff options
author | Pavel Shilovsky <piastry@etersoft.ru> | 2012-09-25 03:00:09 -0400 |
---|---|---|
committer | Steve French <smfrench@gmail.com> | 2012-09-26 23:15:18 -0400 |
commit | 4ca3a99ca4bf8f5dcfc4fef4f2b1d8322bb60ad9 (patch) | |
tree | 33a25d47a71929f62429ad93ec6b64ef88e9ad76 /fs/cifs/smb2pdu.c | |
parent | 760ad0cac198356c1148cad7531c1a6138322493 (diff) |
CIFS: Fix possible freed pointer dereference in SMB2_sess_setup
and remove redundant (rsp == NULL) checks after SendReceive2.
Signed-off-by: Pavel Shilovsky <piastry@etersoft.ru>
Signed-off-by: Steve French <smfrench@gmail.com>
Diffstat (limited to 'fs/cifs/smb2pdu.c')
-rw-r--r-- | fs/cifs/smb2pdu.c | 35 |
1 files changed, 3 insertions, 32 deletions
diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index a7db95f4760c..5ad88b4b9990 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c | |||
@@ -409,11 +409,6 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses) | |||
409 | if (rc != 0) | 409 | if (rc != 0) |
410 | goto neg_exit; | 410 | goto neg_exit; |
411 | 411 | ||
412 | if (rsp == NULL) { | ||
413 | rc = -EIO; | ||
414 | goto neg_exit; | ||
415 | } | ||
416 | |||
417 | cFYI(1, "mode 0x%x", rsp->SecurityMode); | 412 | cFYI(1, "mode 0x%x", rsp->SecurityMode); |
418 | 413 | ||
419 | if (rsp->DialectRevision == smb2protocols[SMB21_PROT].name) | 414 | if (rsp->DialectRevision == smb2protocols[SMB21_PROT].name) |
@@ -637,13 +632,14 @@ ssetup_ntlmssp_authenticate: | |||
637 | 632 | ||
638 | kfree(security_blob); | 633 | kfree(security_blob); |
639 | rsp = (struct smb2_sess_setup_rsp *)iov[0].iov_base; | 634 | rsp = (struct smb2_sess_setup_rsp *)iov[0].iov_base; |
640 | if (rsp->hdr.Status == STATUS_MORE_PROCESSING_REQUIRED) { | 635 | if (resp_buftype != CIFS_NO_BUFFER && |
636 | rsp->hdr.Status == STATUS_MORE_PROCESSING_REQUIRED) { | ||
641 | if (phase != NtLmNegotiate) { | 637 | if (phase != NtLmNegotiate) { |
642 | cERROR(1, "Unexpected more processing error"); | 638 | cERROR(1, "Unexpected more processing error"); |
643 | goto ssetup_exit; | 639 | goto ssetup_exit; |
644 | } | 640 | } |
645 | if (offsetof(struct smb2_sess_setup_rsp, Buffer) - 4 != | 641 | if (offsetof(struct smb2_sess_setup_rsp, Buffer) - 4 != |
646 | le16_to_cpu(rsp->SecurityBufferOffset)) { | 642 | le16_to_cpu(rsp->SecurityBufferOffset)) { |
647 | cERROR(1, "Invalid security buffer offset %d", | 643 | cERROR(1, "Invalid security buffer offset %d", |
648 | le16_to_cpu(rsp->SecurityBufferOffset)); | 644 | le16_to_cpu(rsp->SecurityBufferOffset)); |
649 | rc = -EIO; | 645 | rc = -EIO; |
@@ -669,11 +665,6 @@ ssetup_ntlmssp_authenticate: | |||
669 | if (rc != 0) | 665 | if (rc != 0) |
670 | goto ssetup_exit; | 666 | goto ssetup_exit; |
671 | 667 | ||
672 | if (rsp == NULL) { | ||
673 | rc = -EIO; | ||
674 | goto ssetup_exit; | ||
675 | } | ||
676 | |||
677 | ses->session_flags = le16_to_cpu(rsp->SessionFlags); | 668 | ses->session_flags = le16_to_cpu(rsp->SessionFlags); |
678 | ssetup_exit: | 669 | ssetup_exit: |
679 | free_rsp_buf(resp_buftype, rsp); | 670 | free_rsp_buf(resp_buftype, rsp); |
@@ -793,11 +784,6 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree, | |||
793 | goto tcon_error_exit; | 784 | goto tcon_error_exit; |
794 | } | 785 | } |
795 | 786 | ||
796 | if (rsp == NULL) { | ||
797 | rc = -EIO; | ||
798 | goto tcon_exit; | ||
799 | } | ||
800 | |||
801 | if (tcon == NULL) { | 787 | if (tcon == NULL) { |
802 | ses->ipc_tid = rsp->hdr.TreeId; | 788 | ses->ipc_tid = rsp->hdr.TreeId; |
803 | goto tcon_exit; | 789 | goto tcon_exit; |
@@ -1046,10 +1032,6 @@ SMB2_open(const unsigned int xid, struct cifs_tcon *tcon, __le16 *path, | |||
1046 | goto creat_exit; | 1032 | goto creat_exit; |
1047 | } | 1033 | } |
1048 | 1034 | ||
1049 | if (rsp == NULL) { | ||
1050 | rc = -EIO; | ||
1051 | goto creat_exit; | ||
1052 | } | ||
1053 | *persistent_fid = rsp->PersistentFileId; | 1035 | *persistent_fid = rsp->PersistentFileId; |
1054 | *volatile_fid = rsp->VolatileFileId; | 1036 | *volatile_fid = rsp->VolatileFileId; |
1055 | 1037 | ||
@@ -1111,11 +1093,6 @@ SMB2_close(const unsigned int xid, struct cifs_tcon *tcon, | |||
1111 | goto close_exit; | 1093 | goto close_exit; |
1112 | } | 1094 | } |
1113 | 1095 | ||
1114 | if (rsp == NULL) { | ||
1115 | rc = -EIO; | ||
1116 | goto close_exit; | ||
1117 | } | ||
1118 | |||
1119 | /* BB FIXME - decode close response, update inode for caching */ | 1096 | /* BB FIXME - decode close response, update inode for caching */ |
1120 | 1097 | ||
1121 | close_exit: | 1098 | close_exit: |
@@ -1950,12 +1927,6 @@ send_set_info(const unsigned int xid, struct cifs_tcon *tcon, | |||
1950 | cifs_stats_fail_inc(tcon, SMB2_SET_INFO_HE); | 1927 | cifs_stats_fail_inc(tcon, SMB2_SET_INFO_HE); |
1951 | goto out; | 1928 | goto out; |
1952 | } | 1929 | } |
1953 | |||
1954 | if (rsp == NULL) { | ||
1955 | rc = -EIO; | ||
1956 | goto out; | ||
1957 | } | ||
1958 | |||
1959 | out: | 1930 | out: |
1960 | free_rsp_buf(resp_buftype, rsp); | 1931 | free_rsp_buf(resp_buftype, rsp); |
1961 | kfree(iov); | 1932 | kfree(iov); |