diff options
author | Mike Christie <michael.christie@oracle.com> | 2021-05-25 20:18:06 +0200 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2021-06-02 07:28:21 +0200 |
commit | ec29d0ac29be366450a7faffbcf8cba3a6a3b506 (patch) | |
tree | 7b363b26e9e235c989aac6751f5c691009d458bc /include/scsi/libiscsi.h | |
parent | scsi: iscsi: Get ref to conn during reset handling (diff) | |
download | linux-ec29d0ac29be366450a7faffbcf8cba3a6a3b506.tar.xz linux-ec29d0ac29be366450a7faffbcf8cba3a6a3b506.zip |
scsi: iscsi: Fix conn use after free during resets
If we haven't done a unbind target call we can race where
iscsi_conn_teardown wakes up the EH thread and then frees the conn while
those threads are still accessing the conn ehwait.
We can only do one TMF per session so this just moves the TMF fields from
the conn to the session. We can then rely on the
iscsi_session_teardown->iscsi_remove_session->__iscsi_unbind_session call
to remove the target and it's devices, and know after that point there is
no device or scsi-ml callout trying to access the session.
Link: https://lore.kernel.org/r/20210525181821.7617-14-michael.christie@oracle.com
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'include/scsi/libiscsi.h')
-rw-r--r-- | include/scsi/libiscsi.h | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h index 13d413a0b8b6..9d7908265afe 100644 --- a/include/scsi/libiscsi.h +++ b/include/scsi/libiscsi.h @@ -202,12 +202,6 @@ struct iscsi_conn { unsigned long suspend_tx; /* suspend Tx */ unsigned long suspend_rx; /* suspend Rx */ - /* abort */ - wait_queue_head_t ehwait; /* used in eh_abort() */ - struct iscsi_tm tmhdr; - struct timer_list tmf_timer; - int tmf_state; /* see TMF_INITIAL, etc.*/ - /* negotiated params */ unsigned max_recv_dlength; /* initiator_max_recv_dsl*/ unsigned max_xmit_dlength; /* target_max_recv_dsl */ @@ -277,6 +271,11 @@ struct iscsi_session { * and recv lock. */ struct mutex eh_mutex; + /* abort */ + wait_queue_head_t ehwait; /* used in eh_abort() */ + struct iscsi_tm tmhdr; + struct timer_list tmf_timer; + int tmf_state; /* see TMF_INITIAL, etc.*/ /* iSCSI session-wide sequencing */ uint32_t cmdsn; |