Skip to content

Commit

Permalink
scsi: libiscsi: Fix use-after-free race during iscsi_session_teardown
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Khazhismel Kumykov authored and Martin K. Petersen committed Oct 3, 2017
1 parent 77082ca commit 9e10b51
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/scsi/libiscsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2851,9 +2851,6 @@ EXPORT_SYMBOL_GPL(iscsi_session_setup);
/**
* iscsi_session_teardown - destroy session, host, and cls_session
* @cls_session: iscsi session
*
* The driver must have called iscsi_remove_session before
* calling this.
*/
void iscsi_session_teardown(struct iscsi_cls_session *cls_session)
{
Expand All @@ -2863,6 +2860,8 @@ void iscsi_session_teardown(struct iscsi_cls_session *cls_session)

iscsi_pool_free(&session->cmdpool);

iscsi_remove_session(cls_session);

kfree(session->password);
kfree(session->password_in);
kfree(session->username);
Expand All @@ -2877,7 +2876,8 @@ void iscsi_session_teardown(struct iscsi_cls_session *cls_session)
kfree(session->portal_type);
kfree(session->discovery_parent_type);

iscsi_destroy_session(cls_session);
iscsi_free_session(cls_session);

iscsi_host_dec_session_cnt(shost);
module_put(owner);
}
Expand Down

0 comments on commit 9e10b51

Please sign in to comment.