LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH v2] scsi: libiscsi: move init ehwait to iscsi_session_setup()
@ 2021-09-11 13:51 Ding Hui
  2021-09-13 15:23 ` Mike Christie
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ding Hui @ 2021-09-11 13:51 UTC (permalink / raw)
  To: lduncan, cleech, jejb, martin.petersen, michael.christie,
	open-iscsi, linux-scsi, linux-kernel
  Cc: Ding Hui

The commit ec29d0ac29be ("scsi: iscsi: Fix conn use after free during
resets") move member ehwait from conn to session, but left init ehwait
in iscsi_conn_setup().

Although a session can only have 1 conn currently, it is better to
do init ehwait in iscsi_session_setup() to prevent reinit by mistake,
also in case we can handle multiple conns in the future.

Fixes: ec29d0ac29be ("scsi: iscsi: Fix conn use after free during resets")
Signed-off-by: Ding Hui <dinghui@sangfor.com.cn>
---
v2:
  update commit log
 
 drivers/scsi/libiscsi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 4683c183e9d4..712a45368385 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -2947,6 +2947,7 @@ iscsi_session_setup(struct iscsi_transport *iscsit, struct Scsi_Host *shost,
 	session->tmf_state = TMF_INITIAL;
 	timer_setup(&session->tmf_timer, iscsi_tmf_timedout, 0);
 	mutex_init(&session->eh_mutex);
+	init_waitqueue_head(&session->ehwait);
 
 	spin_lock_init(&session->frwd_lock);
 	spin_lock_init(&session->back_lock);
@@ -3074,8 +3075,6 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, int dd_size,
 		goto login_task_data_alloc_fail;
 	conn->login_task->data = conn->data = data;
 
-	init_waitqueue_head(&session->ehwait);
-
 	return cls_conn;
 
 login_task_data_alloc_fail:
-- 
2.17.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] scsi: libiscsi: move init ehwait to iscsi_session_setup()
  2021-09-11 13:51 [PATCH v2] scsi: libiscsi: move init ehwait to iscsi_session_setup() Ding Hui
@ 2021-09-13 15:23 ` Mike Christie
  2021-09-14  4:05 ` Martin K. Petersen
  2021-09-22  4:45 ` Martin K. Petersen
  2 siblings, 0 replies; 4+ messages in thread
From: Mike Christie @ 2021-09-13 15:23 UTC (permalink / raw)
  To: Ding Hui, lduncan, cleech, jejb, martin.petersen, open-iscsi,
	linux-scsi, linux-kernel

On 9/11/21 8:51 AM, Ding Hui wrote:
> The commit ec29d0ac29be ("scsi: iscsi: Fix conn use after free during
> resets") move member ehwait from conn to session, but left init ehwait
> in iscsi_conn_setup().
> 
> Although a session can only have 1 conn currently, it is better to
> do init ehwait in iscsi_session_setup() to prevent reinit by mistake,
> also in case we can handle multiple conns in the future.
> 
> Fixes: ec29d0ac29be ("scsi: iscsi: Fix conn use after free during resets")
> Signed-off-by: Ding Hui <dinghui@sangfor.com.cn>
> ---
> v2:
>   update commit log
>  
>  drivers/scsi/libiscsi.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
> index 4683c183e9d4..712a45368385 100644
> --- a/drivers/scsi/libiscsi.c
> +++ b/drivers/scsi/libiscsi.c
> @@ -2947,6 +2947,7 @@ iscsi_session_setup(struct iscsi_transport *iscsit, struct Scsi_Host *shost,
>  	session->tmf_state = TMF_INITIAL;
>  	timer_setup(&session->tmf_timer, iscsi_tmf_timedout, 0);
>  	mutex_init(&session->eh_mutex);
> +	init_waitqueue_head(&session->ehwait);
>  
>  	spin_lock_init(&session->frwd_lock);
>  	spin_lock_init(&session->back_lock);
> @@ -3074,8 +3075,6 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, int dd_size,
>  		goto login_task_data_alloc_fail;
>  	conn->login_task->data = conn->data = data;
>  
> -	init_waitqueue_head(&session->ehwait);
> -
>  	return cls_conn;
>  
>  login_task_data_alloc_fail:
> 

Reviewed-by: Mike Christie <michael.christie@oracle.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] scsi: libiscsi: move init ehwait to iscsi_session_setup()
  2021-09-11 13:51 [PATCH v2] scsi: libiscsi: move init ehwait to iscsi_session_setup() Ding Hui
  2021-09-13 15:23 ` Mike Christie
@ 2021-09-14  4:05 ` Martin K. Petersen
  2021-09-22  4:45 ` Martin K. Petersen
  2 siblings, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2021-09-14  4:05 UTC (permalink / raw)
  To: Ding Hui
  Cc: lduncan, cleech, jejb, martin.petersen, michael.christie,
	open-iscsi, linux-scsi, linux-kernel


Ding,

> The commit ec29d0ac29be ("scsi: iscsi: Fix conn use after free during
> resets") move member ehwait from conn to session, but left init ehwait
> in iscsi_conn_setup().
>
> Although a session can only have 1 conn currently, it is better to do
> init ehwait in iscsi_session_setup() to prevent reinit by mistake,
> also in case we can handle multiple conns in the future.

Applied to 5.16/scsi-staging, thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] scsi: libiscsi: move init ehwait to iscsi_session_setup()
  2021-09-11 13:51 [PATCH v2] scsi: libiscsi: move init ehwait to iscsi_session_setup() Ding Hui
  2021-09-13 15:23 ` Mike Christie
  2021-09-14  4:05 ` Martin K. Petersen
@ 2021-09-22  4:45 ` Martin K. Petersen
  2 siblings, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2021-09-22  4:45 UTC (permalink / raw)
  To: michael.christie, lduncan, linux-scsi, linux-kernel, Ding Hui,
	jejb, open-iscsi, cleech
  Cc: Martin K . Petersen

On Sat, 11 Sep 2021 21:51:59 +0800, Ding Hui wrote:

> The commit ec29d0ac29be ("scsi: iscsi: Fix conn use after free during
> resets") move member ehwait from conn to session, but left init ehwait
> in iscsi_conn_setup().
> 
> Although a session can only have 1 conn currently, it is better to
> do init ehwait in iscsi_session_setup() to prevent reinit by mistake,
> also in case we can handle multiple conns in the future.
> 
> [...]

Applied to 5.16/scsi-queue, thanks!

[1/1] scsi: libiscsi: move init ehwait to iscsi_session_setup()
      https://git.kernel.org/mkp/scsi/c/e018f03d6ccb

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-09-22  4:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-11 13:51 [PATCH v2] scsi: libiscsi: move init ehwait to iscsi_session_setup() Ding Hui
2021-09-13 15:23 ` Mike Christie
2021-09-14  4:05 ` Martin K. Petersen
2021-09-22  4:45 ` Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).