* [PATCH] scsi: iscsi_tcp: Check the sock is correct before iscsi_set_param
@ 2023-03-29 7:17 Zhong Jinghua
2023-03-29 15:17 ` Mike Christie
0 siblings, 1 reply; 2+ messages in thread
From: Zhong Jinghua @ 2023-03-29 7:17 UTC (permalink / raw)
To: lduncan, cleech, jejb, martin.petersen
Cc: open-iscsi, linux-scsi, linux-kernel, zhongjinghua, yi.zhang,
yukuai3, houtao1
From: Zhong Jinghua <zhongjinghua@huawei.com>
The correctness of sock should be checked before assignment to avoid
assigning wrong values.
Commit
"scsi: iscsi: iscsi_tcp: Fix null-ptr-deref while calling getpeername()"
introduced this change. This change may lead to inconsistent values of
tcp_sw_conn->sendpage and conn->datadgst_en.
Fix it by moving the position of the assignment.
Fixes: 57569c37f0ad ("scsi: iscsi: iscsi_tcp: Fix null-ptr-deref while calling getpeername()")
Signed-off-by: Zhong Jinghua <zhongjinghua@huawei.com>
---
drivers/scsi/iscsi_tcp.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index 882e8b81b490..b32f3ca3e7d0 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -726,13 +726,12 @@ static int iscsi_sw_tcp_conn_set_param(struct iscsi_cls_conn *cls_conn,
iscsi_set_param(cls_conn, param, buf, buflen);
break;
case ISCSI_PARAM_DATADGST_EN:
- iscsi_set_param(cls_conn, param, buf, buflen);
-
mutex_lock(&tcp_sw_conn->sock_lock);
if (!tcp_sw_conn->sock) {
mutex_unlock(&tcp_sw_conn->sock_lock);
return -ENOTCONN;
}
+ iscsi_set_param(cls_conn, param, buf, buflen);
tcp_sw_conn->sendpage = conn->datadgst_en ?
sock_no_sendpage : tcp_sw_conn->sock->ops->sendpage;
mutex_unlock(&tcp_sw_conn->sock_lock);
--
2.31.1
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] scsi: iscsi_tcp: Check the sock is correct before iscsi_set_param
2023-03-29 7:17 [PATCH] scsi: iscsi_tcp: Check the sock is correct before iscsi_set_param Zhong Jinghua
@ 2023-03-29 15:17 ` Mike Christie
0 siblings, 0 replies; 2+ messages in thread
From: Mike Christie @ 2023-03-29 15:17 UTC (permalink / raw)
To: Zhong Jinghua, lduncan, cleech, jejb, martin.petersen
Cc: open-iscsi, linux-scsi, linux-kernel, zhongjinghua, yi.zhang,
yukuai3, houtao1
On 3/29/23 2:17 AM, Zhong Jinghua wrote:
> From: Zhong Jinghua <zhongjinghua@huawei.com>
>
> The correctness of sock should be checked before assignment to avoid
> assigning wrong values.
>
> Commit
> "scsi: iscsi: iscsi_tcp: Fix null-ptr-deref while calling getpeername()"
> introduced this change. This change may lead to inconsistent values of
> tcp_sw_conn->sendpage and conn->datadgst_en.
>
> Fix it by moving the position of the assignment.
>
> Fixes: 57569c37f0ad ("scsi: iscsi: iscsi_tcp: Fix null-ptr-deref while calling getpeername()")
> Signed-off-by: Zhong Jinghua <zhongjinghua@huawei.com>
Thanks.
Reviewed-by: Mike Christie <michael.christie@oracle.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-03-29 15:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-29 7:17 [PATCH] scsi: iscsi_tcp: Check the sock is correct before iscsi_set_param Zhong Jinghua
2023-03-29 15:17 ` Mike Christie
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®