From: Khazhismel Kumykov <khazhy@google.com>
To: lduncan@suse.com, cleech@redhat.com
Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
open-iscsi@googlegroups.com,
Khazhismel Kumykov <khazhy@google.com>
Subject: [Patch v2 1/2] libiscsi: Fix use-after-free race during iscsi_session_teardown
Date: Thu, 13 Jul 2017 09:11:21 -0700 [thread overview]
Message-ID: <20170713161122.89375-1-khazhy@google.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1398 bytes --]
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>
---
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
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4843 bytes --]
next reply other threads:[~2017-07-13 16:11 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-13 16:11 Khazhismel Kumykov [this message]
2017-07-13 16:11 ` [Patch v2 2/2] libiscsi: Remove iscsi_destroy_session Khazhismel Kumykov
2017-08-29 18:30 ` Chris Leech
2017-09-14 0:09 ` Lee Duncan
2017-09-14 7:57 ` Johannes Thumshirn
2017-08-24 17:33 ` [Patch v2 1/2] libiscsi: Fix use-after-free race during iscsi_session_teardown Khazhismel Kumykov
2017-08-29 18:29 ` Chris Leech
2017-08-30 1:45 ` Martin K. Petersen
2017-09-29 22:54 ` Khazhismel Kumykov
2017-10-03 2:28 ` Martin K. Petersen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170713161122.89375-1-khazhy@google.com \
--to=khazhy@google.com \
--cc=cleech@redhat.com \
--cc=lduncan@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=open-iscsi@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox