[3.13.y.z extended stable] Patch "[SCSI] libiscsi: fix potential buffer overrun in __iscsi_conn_send_pdu" has been added to staging queue

Kamal Mostafa kamal at canonical.com
Thu Oct 9 20:51:38 UTC 2014

This is a note to let you know that I have just added a patch titled

    [SCSI] libiscsi: fix potential buffer overrun in __iscsi_conn_send_pdu

to the linux-3.13.y-queue branch of the 3.13.y.z extended stable tree 
which can be found at:


This patch is scheduled to be released in version

If you, or anyone else, feels it should not be added to this tree, please 
reply to this email.

For more information about the 3.13.y.z tree, see



>From bfdab4b9c1d0c207ab48832f4bb8328424e9650f Mon Sep 17 00:00:00 2001
From: Mike Christie <michaelc at cs.wisc.edu>
Date: Wed, 3 Sep 2014 00:00:39 -0500
Subject: [SCSI] libiscsi: fix potential buffer overrun in

commit db9bfd64b14a3a8f1868d2164518fdeab1b26ad1 upstream.

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:

Reported-by: Dan Carpenter <dan.carpenter at oracle.com>
Signed-off-by: Mike Christie <michaelc at cs.wisc.edu>
Reviewed-by: Sagi Grimberg <sagig at mellanox.com>
Signed-off-by: Christoph Hellwig <hch at lst.de>
Signed-off-by: James Bottomley <JBottomley at Parallels.com>
Signed-off-by: Kamal Mostafa <kamal at canonical.com>
 drivers/scsi/libiscsi.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index e399561..b69b233 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,
 			return NULL;

+		if (data_size > ISCSI_DEF_MAX_RECV_SEG_LEN) {
+			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);
+			return NULL;
+		}
 		task = conn->login_task;
 	} else {
 		if (session->state != ISCSI_STATE_LOGGED_IN)
 			return NULL;

+		if (data_size != 0) {
+			iscsi_conn_printk(KERN_ERR, conn, "Can not send data buffer of len %u for op 0x%x\n", data_size, opcode);
+			return NULL;
+		}
 		BUG_ON(conn->c_stage == ISCSI_CONN_INITIAL_STAGE);
 		BUG_ON(conn->c_stage == ISCSI_CONN_STOPPED);


More information about the kernel-team mailing list