aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-09-19 13:46:48 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-09-19 13:46:48 -0400
commit73030efad5bd280ae9c3b5073710786e6300906e (patch)
tree4b029028c722878b1ee202a12132fec87b98e056
parent598a0c7d0932e385486b173768f03d95bf5507c8 (diff)
parentf81426a84bef870d26e5e752772d8ca203cd4aed (diff)
Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
Pull SCSI fixes from James Bottomley: "This is a set of three fixes. One represents a nasty shared tag map regression (another inverted condition) caused by recent SCSI MQ patches, one is a longstanding potential buffer overrun in the iscsi data buffer and the final one is a use after free for the rare bidirectional commands" * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: [SCSI] fix for bidi use after free [SCSI] fix regression that accidentally disabled block-based tcq [SCSI] libiscsi: fix potential buffer overrun in __iscsi_conn_send_pdu
-rw-r--r--drivers/scsi/libiscsi.c10
-rw-r--r--drivers/scsi/scsi_lib.c5
-rw-r--r--include/scsi/scsi_tcq.h2
3 files changed, 14 insertions, 3 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
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index d837dc180522..aaea4b98af16 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -733,12 +733,13 @@ static bool scsi_end_request(struct request *req, int error,
733 } else { 733 } else {
734 unsigned long flags; 734 unsigned long flags;
735 735
736 if (bidi_bytes)
737 scsi_release_bidi_buffers(cmd);
738
736 spin_lock_irqsave(q->queue_lock, flags); 739 spin_lock_irqsave(q->queue_lock, flags);
737 blk_finish_request(req, error); 740 blk_finish_request(req, error);
738 spin_unlock_irqrestore(q->queue_lock, flags); 741 spin_unlock_irqrestore(q->queue_lock, flags);
739 742
740 if (bidi_bytes)
741 scsi_release_bidi_buffers(cmd);
742 scsi_release_buffers(cmd); 743 scsi_release_buffers(cmd);
743 scsi_next_command(cmd); 744 scsi_next_command(cmd);
744 } 745 }
diff --git a/include/scsi/scsi_tcq.h b/include/scsi/scsi_tcq.h
index cdcc90b07ecb..e64583560701 100644
--- a/include/scsi/scsi_tcq.h
+++ b/include/scsi/scsi_tcq.h
@@ -68,7 +68,7 @@ static inline void scsi_activate_tcq(struct scsi_device *sdev, int depth)
68 return; 68 return;
69 69
70 if (!shost_use_blk_mq(sdev->host) && 70 if (!shost_use_blk_mq(sdev->host) &&
71 blk_queue_tagged(sdev->request_queue)) 71 !blk_queue_tagged(sdev->request_queue))
72 blk_queue_init_tags(sdev->request_queue, depth, 72 blk_queue_init_tags(sdev->request_queue, depth,
73 sdev->host->bqt); 73 sdev->host->bqt);
74 74