From: "Denis V. Lunev" <den@openvz.org>
To: <akpm@linux-foundation.org>
Cc: <linux-kernel@vger.kernel.org>, <linux-scsi@vger.kernel.org>,
Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>,
"James E.J. Bottomley" <James.Bottomley@suse.de>,
"Denis V. Lunev" <den@openvz.org>
Subject: [PATCH 1/2] Crash in linux kernel when disconnecting usb storage
Date: Tue, 3 Nov 2009 12:36:35 +0300 [thread overview]
Message-ID: <1257240996-23118-1-git-send-email-den@openvz.org> (raw)
From: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
__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>
CC: James E.J. Bottomley <James.Bottomley@suse.de>
Signed-off-by: Denis V. Lunev <den@openvz.org>
---
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 5fd2da4..c968cc3 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -164,8 +164,8 @@ void scsi_remove_host(struct Scsi_Host *shost)
return;
}
spin_unlock_irqrestore(shost->host_lock, flags);
- mutex_unlock(&shost->scan_mutex);
scsi_forget_host(shost);
+ mutex_unlock(&shost->scan_mutex);
scsi_proc_host_rm(shost);
spin_lock_irqsave(shost->host_lock, flags);
--
1.6.4.4
next reply other threads:[~2009-11-03 9:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-03 9:36 Denis V. Lunev [this message]
2009-11-03 9:36 ` [PATCH 2/2] Another crash in linux kernel at diconnect of usb strorage Denis V. Lunev
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=1257240996-23118-1-git-send-email-den@openvz.org \
--to=den@openvz.org \
--cc=James.Bottomley@suse.de \
--cc=akpm@linux-foundation.org \
--cc=kuznet@ms2.inr.ac.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
/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
all inboxes | Powered by JetHome®