public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: James Smart <James.Smart@Emulex.Com>
To: linux-scsi@vger.kernel.org
Subject: [PATCH] scsi_scan.c: bug fix: starget use after free issue
Date: Thu, 15 Jun 2006 12:55:59 -0400	[thread overview]
Message-ID: <1150390560.29774.32.camel@localhost.localdomain> (raw)

When reaping the starget, after all sdev's have been removed, the starget
was queued for deletion via usercontext, but was left on the shost's
__targets list. Another scanning thread can match the starget and use it, 
causing reference after free problems.

This patch unlinks the starget at the same time it is scheduled for deletion.

-- james s


Signed-off-by: James Smart <james.smart@emulex.com>

diff -upNr a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
--- a/drivers/scsi/scsi_scan.c	2006-06-14 11:37:09.000000000 -0400
+++ b/drivers/scsi/scsi_scan.c	2006-06-14 16:55:58.000000000 -0400
@@ -415,7 +415,6 @@ static void scsi_target_reap_usercontext
 	spin_lock_irqsave(shost->host_lock, flags);
 	if (shost->hostt->target_destroy)
 		shost->hostt->target_destroy(starget);
-	list_del_init(&starget->siblings);
 	spin_unlock_irqrestore(shost->host_lock, flags);
 	put_device(&starget->dev);
 }
@@ -439,6 +438,7 @@ void scsi_target_reap(struct scsi_target
 	if (--starget->reap_ref == 0 && list_empty(&starget->devices)) {
 		BUG_ON(starget->state == STARGET_DEL);
 		starget->state = STARGET_DEL;
+		list_del_init(&starget->siblings);
 		spin_unlock_irqrestore(shost->host_lock, flags);
 		execute_in_process_context(scsi_target_reap_usercontext,
 					   starget, &starget->ew);



             reply	other threads:[~2006-06-15 16:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-15 16:55 James Smart [this message]
2006-06-27 15:58 ` [PATCH] scsi_scan.c: bug fix: starget use after free issue James Bottomley
2006-06-27 16:39   ` James Smart
2006-07-19 14:22 ` 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=1150390560.29774.32.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