Skip to content

Commit 9e10b51

Browse files
khazhykmartinkpetersen
authored andcommitted
scsi: libiscsi: Fix use-after-free race during iscsi_session_teardown
Session attributes exposed through sysfs were freed before the device was destroyed, resulting in a potential use-after-free. Free these attributes after removing the device. Signed-off-by: Khazhismel Kumykov <khazhy@google.com> Acked-by: Chris Leech <cleech@redhat.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 77082ca commit 9e10b51

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

drivers/scsi/libiscsi.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2851,9 +2851,6 @@ EXPORT_SYMBOL_GPL(iscsi_session_setup);
28512851
/**
28522852
* iscsi_session_teardown - destroy session, host, and cls_session
28532853
* @cls_session: iscsi session
2854-
*
2855-
* The driver must have called iscsi_remove_session before
2856-
* calling this.
28572854
*/
28582855
void iscsi_session_teardown(struct iscsi_cls_session *cls_session)
28592856
{
@@ -2863,6 +2860,8 @@ void iscsi_session_teardown(struct iscsi_cls_session *cls_session)
28632860

28642861
iscsi_pool_free(&session->cmdpool);
28652862

2863+
iscsi_remove_session(cls_session);
2864+
28662865
kfree(session->password);
28672866
kfree(session->password_in);
28682867
kfree(session->username);
@@ -2877,7 +2876,8 @@ void iscsi_session_teardown(struct iscsi_cls_session *cls_session)
28772876
kfree(session->portal_type);
28782877
kfree(session->discovery_parent_type);
28792878

2880-
iscsi_destroy_session(cls_session);
2879+
iscsi_free_session(cls_session);
2880+
28812881
iscsi_host_dec_session_cnt(shost);
28822882
module_put(owner);
28832883
}

0 commit comments

Comments
 (0)