Skip to content

Commit 73030ef

Browse files
committed
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
2 parents 598a0c7 + f81426a commit 73030ef

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

drivers/scsi/libiscsi.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,11 +717,21 @@ __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
717717
return NULL;
718718
}
719719

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+
720725
task = conn->login_task;
721726
} else {
722727
if (session->state != ISCSI_STATE_LOGGED_IN)
723728
return NULL;
724729

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+
725735
BUG_ON(conn->c_stage == ISCSI_CONN_INITIAL_STAGE);
726736
BUG_ON(conn->c_stage == ISCSI_CONN_STOPPED);
727737

drivers/scsi/scsi_lib.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -733,12 +733,13 @@ static bool scsi_end_request(struct request *req, int error,
733733
} else {
734734
unsigned long flags;
735735

736+
if (bidi_bytes)
737+
scsi_release_bidi_buffers(cmd);
738+
736739
spin_lock_irqsave(q->queue_lock, flags);
737740
blk_finish_request(req, error);
738741
spin_unlock_irqrestore(q->queue_lock, flags);
739742

740-
if (bidi_bytes)
741-
scsi_release_bidi_buffers(cmd);
742743
scsi_release_buffers(cmd);
743744
scsi_next_command(cmd);
744745
}

include/scsi/scsi_tcq.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ static inline void scsi_activate_tcq(struct scsi_device *sdev, int depth)
6868
return;
6969

7070
if (!shost_use_blk_mq(sdev->host) &&
71-
blk_queue_tagged(sdev->request_queue))
71+
!blk_queue_tagged(sdev->request_queue))
7272
blk_queue_init_tags(sdev->request_queue, depth,
7373
sdev->host->bqt);
7474

0 commit comments

Comments
 (0)