[SCSI] libiscsi_tcp: fix max_r2t manipulation
Problem description from Xi Wang: A large max_r2t could lead to integer overflow in subsequent call to iscsi_tcp_r2tpool_alloc(), allocating a smaller buffer than expected and leading to out-of-bounds write. Signed-off-by: Mike Christie <michaelc@cs.wisc.edu> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
This commit is contained in:

committed by
James Bottomley

parent
df1c7baba1
commit
1304be5fe0
@@ -684,10 +684,8 @@ static int iscsi_sw_tcp_conn_set_param(struct iscsi_cls_conn *cls_conn,
|
||||
int buflen)
|
||||
{
|
||||
struct iscsi_conn *conn = cls_conn->dd_data;
|
||||
struct iscsi_session *session = conn->session;
|
||||
struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
|
||||
struct iscsi_sw_tcp_conn *tcp_sw_conn = tcp_conn->dd_data;
|
||||
int value;
|
||||
|
||||
switch(param) {
|
||||
case ISCSI_PARAM_HDRDGST_EN:
|
||||
@@ -699,16 +697,7 @@ static int iscsi_sw_tcp_conn_set_param(struct iscsi_cls_conn *cls_conn,
|
||||
sock_no_sendpage : tcp_sw_conn->sock->ops->sendpage;
|
||||
break;
|
||||
case ISCSI_PARAM_MAX_R2T:
|
||||
sscanf(buf, "%d", &value);
|
||||
if (value <= 0 || !is_power_of_2(value))
|
||||
return -EINVAL;
|
||||
if (session->max_r2t == value)
|
||||
break;
|
||||
iscsi_tcp_r2tpool_free(session);
|
||||
iscsi_set_param(cls_conn, param, buf, buflen);
|
||||
if (iscsi_tcp_r2tpool_alloc(session))
|
||||
return -ENOMEM;
|
||||
break;
|
||||
return iscsi_tcp_set_max_r2t(conn, buf);
|
||||
default:
|
||||
return iscsi_set_param(cls_conn, param, buf, buflen);
|
||||
}
|
||||
|
Reference in New Issue
Block a user