mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-29 14:05:19 +08:00
scsi: iscsi_tcp: Check that sock is valid before iscsi_set_param()
[ Upstream commit48b19b79cf
] The validity of sock should be checked before assignment to avoid incorrect values. Commit57569c37f0
("scsi: iscsi: iscsi_tcp: Fix null-ptr-deref while calling getpeername()") introduced this change which may lead to inconsistent values of tcp_sw_conn->sendpage and conn->datadgst_en. Fix the issue by moving the position of the assignment. Fixes:57569c37f0
("scsi: iscsi: iscsi_tcp: Fix null-ptr-deref while calling getpeername()") Signed-off-by: Zhong Jinghua <zhongjinghua@huawei.com> Link: https://lore.kernel.org/r/20230329071739.2175268-1-zhongjinghua@huaweicloud.com Reviewed-by: Mike Christie <michael.christie@oracle.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
ae73c4dd48
commit
5e5c5f4729
@ -767,13 +767,12 @@ static int iscsi_sw_tcp_conn_set_param(struct iscsi_cls_conn *cls_conn,
|
|||||||
iscsi_set_param(cls_conn, param, buf, buflen);
|
iscsi_set_param(cls_conn, param, buf, buflen);
|
||||||
break;
|
break;
|
||||||
case ISCSI_PARAM_DATADGST_EN:
|
case ISCSI_PARAM_DATADGST_EN:
|
||||||
iscsi_set_param(cls_conn, param, buf, buflen);
|
|
||||||
|
|
||||||
mutex_lock(&tcp_sw_conn->sock_lock);
|
mutex_lock(&tcp_sw_conn->sock_lock);
|
||||||
if (!tcp_sw_conn->sock) {
|
if (!tcp_sw_conn->sock) {
|
||||||
mutex_unlock(&tcp_sw_conn->sock_lock);
|
mutex_unlock(&tcp_sw_conn->sock_lock);
|
||||||
return -ENOTCONN;
|
return -ENOTCONN;
|
||||||
}
|
}
|
||||||
|
iscsi_set_param(cls_conn, param, buf, buflen);
|
||||||
tcp_sw_conn->sendpage = conn->datadgst_en ?
|
tcp_sw_conn->sendpage = conn->datadgst_en ?
|
||||||
sock_no_sendpage : tcp_sw_conn->sock->ops->sendpage;
|
sock_no_sendpage : tcp_sw_conn->sock->ops->sendpage;
|
||||||
mutex_unlock(&tcp_sw_conn->sock_lock);
|
mutex_unlock(&tcp_sw_conn->sock_lock);
|
||||||
|
Loading…
Reference in New Issue
Block a user