[3.13.y.z extended stable] Patch "be2iscsi: check ip buffer before copying" has been added to staging queue

Kamal Mostafa kamal at canonical.com
Tue Oct 21 20:09:25 UTC 2014

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

    be2iscsi: check ip buffer before copying

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 979fe2abac7e081e5db10c57195e55ec88380317 Mon Sep 17 00:00:00 2001
From: Mike Christie <michaelc at cs.wisc.edu>
Date: Mon, 29 Sep 2014 13:55:41 -0500
Subject: be2iscsi: check ip buffer before copying

commit a41a9ad3bbf61fae0b6bfb232153da60d14fdbd9 upstream.

Dan Carpenter found a issue where be2iscsi would copy the ip
from userspace to the driver buffer before checking the len
of the data being copied:

This patch just has us only copy what we the driver buffer
can support.

Tested-by: John Soni Jose <sony.john-n at emulex.com>
Signed-off-by: Mike Christie <michaelc at cs.wisc.edu>
Signed-off-by: Christoph Hellwig <hch at lst.de>
Signed-off-by: Kamal Mostafa <kamal at canonical.com>
 drivers/scsi/be2iscsi/be_mgmt.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_mgmt.c b/drivers/scsi/be2iscsi/be_mgmt.c
index b2fcac7..5bb9406 100644
--- a/drivers/scsi/be2iscsi/be_mgmt.c
+++ b/drivers/scsi/be2iscsi/be_mgmt.c
@@ -897,17 +897,20 @@ mgmt_static_ip_modify(struct beiscsi_hba *phba,

 	if (ip_action == IP_ACTION_ADD) {
 		memcpy(req->ip_params.ip_record.ip_addr.addr, ip_param->value,
-		       ip_param->len);
+		       sizeof(req->ip_params.ip_record.ip_addr.addr));

 		if (subnet_param)
-			       subnet_param->value, subnet_param->len);
+			       subnet_param->value,
+			       sizeof(req->ip_params.ip_record.ip_addr.subnet_mask));
 	} else {
-		       if_info->ip_addr.addr, ip_param->len);
+		       if_info->ip_addr.addr,
+		       sizeof(req->ip_params.ip_record.ip_addr.addr));

-		       if_info->ip_addr.subnet_mask, ip_param->len);
+		       if_info->ip_addr.subnet_mask,
+		       sizeof(req->ip_params.ip_record.ip_addr.subnet_mask));

 	rc = mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, NULL, 0);
@@ -935,7 +938,7 @@ static int mgmt_modify_gateway(struct beiscsi_hba *phba, uint8_t *gt_addr,
 	req->action = gtway_action;
 	req->ip_addr.ip_type = BE2_IPV4;

-	memcpy(req->ip_addr.addr, gt_addr, param_len);
+	memcpy(req->ip_addr.addr, gt_addr, sizeof(req->ip_addr.addr));

 	return mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, NULL, 0);

More information about the kernel-team mailing list