From: James Smart <James.Smart@Emulex.Com>
To: linux-scsi@vger.kernel.org
Subject: [PATCH] scsi midlayer: fix sdev reuse after free
Date: Mon, 26 Jun 2006 14:53:47 -0400 [thread overview]
Message-ID: <1151348028.5883.16.camel@localhost.localdomain> (raw)
The conversion to execute_in_process_context() highlighted a use-after-free
race condition. Although the sdev was torn down, it remained in the linked
lists looked at by scan, and allowed scan to reuse the sdev.
This patch removes the sdev from the lists at the point it tears down the
sdev.
-- james s
Signed-off-by: James Smart <james.smart@emulex.com>
diff -upNr a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
--- a/drivers/scsi/scsi_sysfs.c 2006-06-14 11:37:09.000000000 -0400
+++ b/drivers/scsi/scsi_sysfs.c 2006-06-26 14:48:31.000000000 -0400
@@ -231,8 +231,6 @@ static void scsi_device_dev_release_user
spin_lock_irqsave(sdev->host->host_lock, flags);
starget->reap_ref++;
- list_del(&sdev->siblings);
- list_del(&sdev->same_target_siblings);
list_del(&sdev->starved_entry);
spin_unlock_irqrestore(sdev->host->host_lock, flags);
@@ -735,10 +733,15 @@ int scsi_sysfs_add_sdev(struct scsi_devi
void __scsi_remove_device(struct scsi_device *sdev)
{
struct device *dev = &sdev->sdev_gendev;
+ unsigned long flags;
if (scsi_device_set_state(sdev, SDEV_CANCEL) != 0)
return;
+ spin_lock_irqsave(sdev->host->host_lock, flags);
+ list_del(&sdev->siblings);
+ list_del(&sdev->same_target_siblings);
+ spin_unlock_irqrestore(sdev->host->host_lock, flags);
class_device_unregister(&sdev->sdev_classdev);
transport_remove_device(dev);
device_del(dev);
next reply other threads:[~2006-06-26 18:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-06-26 18:53 James Smart [this message]
2006-06-27 16:03 ` [PATCH] scsi midlayer: fix sdev reuse after free James Bottomley
2006-06-27 16:42 ` James Smart
2006-07-19 14:04 ` Frederic TEMPORELLI
2006-07-19 14:11 ` James Smart
2006-07-19 14:12 ` James Smart
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=1151348028.5883.16.camel@localhost.localdomain \
--to=james.smart@emulex.com \
--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