aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/libiscsi.c
diff options
context:
space:
mode:
authorMike Christie <michaelc@cs.wisc.edu>2014-09-03 01:00:39 -0400
committerChristoph Hellwig <hch@lst.de>2014-09-15 17:11:20 -0400
commitcbaa42213461e9a722a391b3800d7c111de7049b (patch)
tree3799037192bc9e23b2e67e2b2b76db60f9e2a7da /drivers/scsi/libiscsi.c
parentf3b5933190c1fc5ad8f3a1dec594e9e849e088c0 (diff)
libiscsi: fix potential buffer overrun in __iscsi_conn_send_pdu
This patches fixes a potential buffer overrun in __iscsi_conn_send_pdu. This function is used by iscsi drivers and userspace to send iscsi PDUs/ commands. For login commands, we have a set buffer size. For all other commands we do not support data buffers. This was reported by Dan Carpenter here: http://www.spinics.net/lists/linux-scsi/msg66838.html Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Mike Christie <michaelc@cs.wisc.edu> Reviewed-by: Sagi Grimberg <sagig@mellanox.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'drivers/scsi/libiscsi.c')
-rw-r--r--drivers/scsi/libiscsi.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index ea025e4806b6..191b59793519 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -717,11 +717,21 @@ __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
717 return NULL; 717 return NULL;
718 } 718 }
719 719
720 if (data_size > ISCSI_DEF_MAX_RECV_SEG_LEN) {
721 iscsi_conn_printk(KERN_ERR, conn, "Invalid buffer len of %u for login task. Max len is %u\n", data_size, ISCSI_DEF_MAX_RECV_SEG_LEN);
722 return NULL;
723 }
724
720 task = conn->login_task; 725 task = conn->login_task;
721 } else { 726 } else {
722 if (session->state != ISCSI_STATE_LOGGED_IN) 727 if (session->state != ISCSI_STATE_LOGGED_IN)
723 return NULL; 728 return NULL;
724 729
730 if (data_size != 0) {
731 iscsi_conn_printk(KERN_ERR, conn, "Can not send data buffer of len %u for op 0x%x\n", data_size, opcode);
732 return NULL;
733 }
734
725 BUG_ON(conn->c_stage == ISCSI_CONN_INITIAL_STAGE); 735 BUG_ON(conn->c_stage == ISCSI_CONN_INITIAL_STAGE);
726 BUG_ON(conn->c_stage == ISCSI_CONN_STOPPED); 736 BUG_ON(conn->c_stage == ISCSI_CONN_STOPPED);
727 737