diff options
author | Khazhismel Kumykov <khazhy@google.com> | 2017-07-13 12:11:21 -0400 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2017-10-02 22:23:21 -0400 |
commit | 9e10b5121ad991ea6e84ca40b15a04cdc551bfe9 (patch) | |
tree | 46ec66e479d194da6637be04d20d8ea9d243a8c5 | |
parent | 77082ca503bed061f7fbda7cfd7c93beda967a41 (diff) |
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>
-rw-r--r-- | drivers/scsi/libiscsi.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index bd4605a34f54..c62e8d111fd9 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c | |||
@@ -2851,9 +2851,6 @@ EXPORT_SYMBOL_GPL(iscsi_session_setup); | |||
2851 | /** | 2851 | /** |
2852 | * iscsi_session_teardown - destroy session, host, and cls_session | 2852 | * iscsi_session_teardown - destroy session, host, and cls_session |
2853 | * @cls_session: iscsi session | 2853 | * @cls_session: iscsi session |
2854 | * | ||
2855 | * The driver must have called iscsi_remove_session before | ||
2856 | * calling this. | ||
2857 | */ | 2854 | */ |
2858 | void iscsi_session_teardown(struct iscsi_cls_session *cls_session) | 2855 | void iscsi_session_teardown(struct iscsi_cls_session *cls_session) |
2859 | { | 2856 | { |
@@ -2863,6 +2860,8 @@ void iscsi_session_teardown(struct iscsi_cls_session *cls_session) | |||
2863 | 2860 | ||
2864 | iscsi_pool_free(&session->cmdpool); | 2861 | iscsi_pool_free(&session->cmdpool); |
2865 | 2862 | ||
2863 | iscsi_remove_session(cls_session); | ||
2864 | |||
2866 | kfree(session->password); | 2865 | kfree(session->password); |
2867 | kfree(session->password_in); | 2866 | kfree(session->password_in); |
2868 | kfree(session->username); | 2867 | kfree(session->username); |
@@ -2877,7 +2876,8 @@ void iscsi_session_teardown(struct iscsi_cls_session *cls_session) | |||
2877 | kfree(session->portal_type); | 2876 | kfree(session->portal_type); |
2878 | kfree(session->discovery_parent_type); | 2877 | kfree(session->discovery_parent_type); |
2879 | 2878 | ||
2880 | iscsi_destroy_session(cls_session); | 2879 | iscsi_free_session(cls_session); |
2880 | |||
2881 | iscsi_host_dec_session_cnt(shost); | 2881 | iscsi_host_dec_session_cnt(shost); |
2882 | module_put(owner); | 2882 | module_put(owner); |
2883 | } | 2883 | } |