diff options
author | Mike Christie <michaelc@cs.wisc.edu> | 2012-01-26 22:13:10 -0500 |
---|---|---|
committer | James Bottomley <JBottomley@Parallels.com> | 2012-02-19 09:09:00 -0500 |
commit | 1304be5fe0efb42b7ec6a50dd8e1a9bce2adae17 (patch) | |
tree | bc3d95ab7c1cc5d779df4696aaa138b7cbd89825 /drivers/scsi/cxgbi | |
parent | df1c7baba1b7b3053950f3845a6575aca47ba9ce (diff) |
[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>
Diffstat (limited to 'drivers/scsi/cxgbi')
-rw-r--r-- | drivers/scsi/cxgbi/libcxgbi.c | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c index d3ff9cd40234..e6e6aa9289b8 100644 --- a/drivers/scsi/cxgbi/libcxgbi.c +++ b/drivers/scsi/cxgbi/libcxgbi.c | |||
@@ -2148,11 +2148,10 @@ int cxgbi_set_conn_param(struct iscsi_cls_conn *cls_conn, | |||
2148 | enum iscsi_param param, char *buf, int buflen) | 2148 | enum iscsi_param param, char *buf, int buflen) |
2149 | { | 2149 | { |
2150 | struct iscsi_conn *conn = cls_conn->dd_data; | 2150 | struct iscsi_conn *conn = cls_conn->dd_data; |
2151 | struct iscsi_session *session = conn->session; | ||
2152 | struct iscsi_tcp_conn *tcp_conn = conn->dd_data; | 2151 | struct iscsi_tcp_conn *tcp_conn = conn->dd_data; |
2153 | struct cxgbi_conn *cconn = tcp_conn->dd_data; | 2152 | struct cxgbi_conn *cconn = tcp_conn->dd_data; |
2154 | struct cxgbi_sock *csk = cconn->cep->csk; | 2153 | struct cxgbi_sock *csk = cconn->cep->csk; |
2155 | int value, err = 0; | 2154 | int err; |
2156 | 2155 | ||
2157 | log_debug(1 << CXGBI_DBG_ISCSI, | 2156 | log_debug(1 << CXGBI_DBG_ISCSI, |
2158 | "cls_conn 0x%p, param %d, buf(%d) %s.\n", | 2157 | "cls_conn 0x%p, param %d, buf(%d) %s.\n", |
@@ -2174,15 +2173,7 @@ int cxgbi_set_conn_param(struct iscsi_cls_conn *cls_conn, | |||
2174 | conn->datadgst_en, 0); | 2173 | conn->datadgst_en, 0); |
2175 | break; | 2174 | break; |
2176 | case ISCSI_PARAM_MAX_R2T: | 2175 | case ISCSI_PARAM_MAX_R2T: |
2177 | sscanf(buf, "%d", &value); | 2176 | return iscsi_tcp_set_max_r2t(conn, buf); |
2178 | if (value <= 0 || !is_power_of_2(value)) | ||
2179 | return -EINVAL; | ||
2180 | if (session->max_r2t == value) | ||
2181 | break; | ||
2182 | iscsi_tcp_r2tpool_free(session); | ||
2183 | err = iscsi_set_param(cls_conn, param, buf, buflen); | ||
2184 | if (!err && iscsi_tcp_r2tpool_alloc(session)) | ||
2185 | return -ENOMEM; | ||
2186 | case ISCSI_PARAM_MAX_RECV_DLENGTH: | 2177 | case ISCSI_PARAM_MAX_RECV_DLENGTH: |
2187 | err = iscsi_set_param(cls_conn, param, buf, buflen); | 2178 | err = iscsi_set_param(cls_conn, param, buf, buflen); |
2188 | if (!err) | 2179 | if (!err) |