scsi: iscsi: Fix conn use after free during resets
authorMike Christie <michael.christie@oracle.com>
Tue, 25 May 2021 18:18:06 +0000 (13:18 -0500)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 2 Jun 2021 05:28:21 +0000 (01:28 -0400)
commitec29d0ac29be366450a7faffbcf8cba3a6a3b506
tree7b363b26e9e235c989aac6751f5c691009d458bc
parentfda290c5ae98b591797c96e55a2cfbd30d46a706
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>
drivers/scsi/libiscsi.c
include/scsi/libiscsi.h