Commit a41a9ad3 authored by Mike Christie's avatar Mike Christie Committed by Christoph Hellwig

be2iscsi: check ip buffer before copying

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:
http://marc.info/?l=linux-scsi&m=140982651504251&w=2

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

Cc: <stable@vger.kernel.org>
Tested-by: default avatarJohn Soni Jose <sony.john-n@emulex.com>
Signed-off-by: default avatarMike Christie <michaelc@cs.wisc.edu>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent 4bfb8ebf
...@@ -943,17 +943,20 @@ mgmt_static_ip_modify(struct beiscsi_hba *phba, ...@@ -943,17 +943,20 @@ mgmt_static_ip_modify(struct beiscsi_hba *phba,
if (ip_action == IP_ACTION_ADD) { if (ip_action == IP_ACTION_ADD) {
memcpy(req->ip_params.ip_record.ip_addr.addr, ip_param->value, 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) if (subnet_param)
memcpy(req->ip_params.ip_record.ip_addr.subnet_mask, memcpy(req->ip_params.ip_record.ip_addr.subnet_mask,
subnet_param->value, subnet_param->len); subnet_param->value,
sizeof(req->ip_params.ip_record.ip_addr.subnet_mask));
} else { } else {
memcpy(req->ip_params.ip_record.ip_addr.addr, memcpy(req->ip_params.ip_record.ip_addr.addr,
if_info->ip_addr.addr, ip_param->len); if_info->ip_addr.addr,
sizeof(req->ip_params.ip_record.ip_addr.addr));
memcpy(req->ip_params.ip_record.ip_addr.subnet_mask, memcpy(req->ip_params.ip_record.ip_addr.subnet_mask,
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); rc = mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, NULL, 0);
...@@ -981,7 +984,7 @@ static int mgmt_modify_gateway(struct beiscsi_hba *phba, uint8_t *gt_addr, ...@@ -981,7 +984,7 @@ static int mgmt_modify_gateway(struct beiscsi_hba *phba, uint8_t *gt_addr,
req->action = gtway_action; req->action = gtway_action;
req->ip_addr.ip_type = BE2_IPV4; 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); return mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, NULL, 0);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment