diff options
author | Alexey Kuznetsov <kuznet@ms2.inr.ac.ru> | 2009-11-17 17:10:11 -0500 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2009-11-26 11:04:22 -0500 |
commit | 4e46bf89972b9d98a9f282a9fed2359756a5e34e (patch) | |
tree | 7e55e191d74412735f8e9cd96e50dd50f34b9a5e /drivers/scsi | |
parent | 860dc73608a091e0b325218acc2701709d5f221a (diff) |
[SCSI] fix crash when disconnecting usb storage
__scsi_remove_device() in scsi_forget_host() is executed out of scan_mutex
and races with scsi_destroy_sdev() <- scsi_sysfs_add_devices() <-
scsi_finish_async_scan(). The result is use after free and/or double
free, oops.
The fix is simple, move scsi_forget_host() under scan_mutex.
scsi_forget_host() is just sequence of __scsi_remove_device(). All
another calls of __scsi_remove_device() are made under scan_mutex. So
that it is safe.
Signed-off-by: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
Signed-off-by: Denis V. Lunev <den@openvz.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/hosts.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c index 5fd2da494d08..c968cc31cd86 100644 --- a/drivers/scsi/hosts.c +++ b/drivers/scsi/hosts.c | |||
@@ -164,8 +164,8 @@ void scsi_remove_host(struct Scsi_Host *shost) | |||
164 | return; | 164 | return; |
165 | } | 165 | } |
166 | spin_unlock_irqrestore(shost->host_lock, flags); | 166 | spin_unlock_irqrestore(shost->host_lock, flags); |
167 | mutex_unlock(&shost->scan_mutex); | ||
168 | scsi_forget_host(shost); | 167 | scsi_forget_host(shost); |
168 | mutex_unlock(&shost->scan_mutex); | ||
169 | scsi_proc_host_rm(shost); | 169 | scsi_proc_host_rm(shost); |
170 | 170 | ||
171 | spin_lock_irqsave(shost->host_lock, flags); | 171 | spin_lock_irqsave(shost->host_lock, flags); |