[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20170713161122.89375-1-khazhy@google.com>
Date: Thu, 13 Jul 2017 09:11:21 -0700
From: Khazhismel Kumykov <khazhy@...gle.com>
To: lduncan@...e.com, cleech@...hat.com
Cc: linux-scsi@...r.kernel.org, linux-kernel@...r.kernel.org,
open-iscsi@...glegroups.com, Khazhismel Kumykov <khazhy@...gle.com>
Subject: [Patch v2 1/2] 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@...gle.com>
---
drivers/scsi/libiscsi.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 42381adf0769..8696a51a5a0c 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -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)
{
@@ -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);
@@ -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);
}
--
2.13.2.932.g7449e964c-goog
Download attachment "smime.p7s" of type "application/pkcs7-signature" (4843 bytes)
Powered by blists - more mailing lists