From: James Bottomley <James.Bottomley@steeleye.com>
To: Jens Axboe <axboe@suse.de>
Cc: James Bottomley <James.Bottomley@SteelEye.com>,
Badari Pulavarty <pbadari@us.ibm.com>,
Andrew Morton <akpm@digeo.com>,
"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
"Martin J. Bligh" <Martin.Bligh@us.ibm.com>,
Doug Ledford <dledford@redhat.com>
Subject: Re: possible use-after-free in 2.5.44 scsi changes
Date: Sat, 26 Oct 2002 19:50:25 -0500 [thread overview]
Message-ID: <200210270050.g9R0oQe04795@localhost.localdomain> (raw)
In-Reply-To: Message from Jens Axboe <axboe@suse.de> of "Sat, 26 Oct 2002 11:29:43 +0200." <20021026092943.GB14976@suse.de>
[-- Attachment #1: Type: text/plain, Size: 315 bytes --]
axboe@suse.de said:
> Irk no, you cannot just clear valid information! This is _not_ a fix,
> it's a hack.
> Use a different flag, or maybe use REQ_DONTPREP or similar.
OK, what about this. It uses REQ_DONTPREP, and could be a precursor to moving
the SCSI subsystem to using the request prep function.
James
[-- Attachment #2: tmp.diff --]
[-- Type: text/plain , Size: 2773 bytes --]
# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
# ChangeSet 1.823 -> 1.824
# drivers/scsi/scsi.h 1.30 -> 1.31
# drivers/scsi/scsi_lib.c 1.36 -> 1.37
# drivers/scsi/scsi.c 1.50 -> 1.51
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 02/10/26 jejb@mulgrave.(none) 1.824
# [SCSI] fix memory etc. leak caused by double preparing requeued commands
# --------------------------------------------
#
diff -Nru a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
--- a/drivers/scsi/scsi.c Sat Oct 26 19:46:01 2002
+++ b/drivers/scsi/scsi.c Sat Oct 26 19:46:01 2002
@@ -658,7 +658,7 @@
* Notes: This could be called either from an interrupt context or a
* normal process context.
*/
-static int scsi_mlqueue_insert(Scsi_Cmnd * cmd, int reason)
+int scsi_mlqueue_insert(Scsi_Cmnd * cmd, int reason)
{
struct Scsi_Host *host = cmd->host;
unsigned long flags;
diff -Nru a/drivers/scsi/scsi.h b/drivers/scsi/scsi.h
--- a/drivers/scsi/scsi.h Sat Oct 26 19:46:01 2002
+++ b/drivers/scsi/scsi.h Sat Oct 26 19:46:01 2002
@@ -480,6 +480,7 @@
void (*done) (struct scsi_cmnd *),
int timeout, int retries);
extern int scsi_dev_init(void);
+extern int scsi_mlqueue_insert(struct scsi_cmnd *, int);
/*
* Newer request-based interfaces.
diff -Nru a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
--- a/drivers/scsi/scsi_lib.c Sat Oct 26 19:46:01 2002
+++ b/drivers/scsi/scsi_lib.c Sat Oct 26 19:46:01 2002
@@ -1005,7 +1005,8 @@
req = NULL;
spin_unlock_irq(q->queue_lock);
- if (SCpnt->request->flags & (REQ_CMD | REQ_BLOCK_PC)) {
+ if (!(SCpnt->request->flags & REQ_DONTPREP)
+ && (SCpnt->request->flags & (REQ_CMD | REQ_BLOCK_PC))) {
/*
* This will do a couple of things:
* 1) Fill in the actual SCSI command.
@@ -1026,18 +1027,8 @@
* required).
*/
if (!scsi_init_io(SCpnt)) {
+ scsi_mlqueue_insert(SCpnt, SCSI_MLQUEUE_DEVICE_BUSY);
spin_lock_irq(q->queue_lock);
- SHpnt->host_busy--;
- SDpnt->device_busy--;
- if (SDpnt->device_busy == 0) {
- SDpnt->starved = 1;
- SHpnt->some_device_starved = 1;
- }
- SCpnt->request->special = SCpnt;
- SCpnt->request->flags |= REQ_SPECIAL;
- if(blk_rq_tagged(SCpnt->request))
- blk_queue_end_tag(q, SCpnt->request);
- _elv_add_request(q, SCpnt->request, 0, 0);
break;
}
@@ -1058,6 +1049,7 @@
continue;
}
}
+ SCpnt->request->flags |= REQ_DONTPREP;
/*
* Finally, initialize any error handling parameters, and set up
* the timers for timeouts.
next prev parent reply other threads:[~2002-10-27 0:50 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-10-25 1:39 possible use-after-free in 2.5.44 scsi changes Andrew Morton
2002-10-25 4:06 ` Doug Ledford
2002-10-25 4:40 ` Andrew Morton
2002-10-25 14:21 ` James Bottomley
2002-10-25 4:07 ` Patrick Mansfield
2002-10-25 14:16 ` James Bottomley
2002-10-25 18:34 ` James Bottomley
2002-10-25 18:49 ` Mike Anderson
2002-10-25 19:08 ` Patrick Mansfield
2002-10-25 19:41 ` Mike Anderson
2002-10-25 19:47 ` Jens Axboe
2002-10-25 22:14 ` James Bottomley
2002-10-25 22:18 ` Andrew Morton
2002-10-25 22:23 ` Badari Pulavarty
2002-10-26 0:13 ` James Bottomley
2002-10-26 0:18 ` Mike Anderson
2002-10-26 9:29 ` Jens Axboe
2002-10-27 0:50 ` James Bottomley [this message]
2002-10-27 21:20 ` Jens Axboe
2002-10-27 21:37 ` James Bottomley
2002-10-27 21:54 ` Jens Axboe
2002-10-30 17:39 ` Badari Pulavarty
2002-10-30 18:16 ` Jens Axboe
2002-10-30 19:31 ` Badari Pulavarty
2002-10-30 21:36 ` merlin hughes
2002-10-30 22:19 ` Badari Pulavarty
2002-10-31 2:17 ` merlin
2002-10-31 13:18 ` Jens Axboe
2002-10-31 14:41 ` merlin
2002-10-31 14:46 ` Jens Axboe
2002-10-31 15:04 ` Jens Axboe
2002-10-31 15:12 ` Jens Axboe
2002-10-31 17:41 ` merlin
2002-10-30 20:35 ` David S. Miller
2002-10-30 22:03 ` Badari Pulavarty
-- strict thread matches above, loose matches on Subject: below --
2002-10-31 17:57 Badari Pulavarty
2002-10-31 18:46 ` Jens Axboe
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=200210270050.g9R0oQe04795@localhost.localdomain \
--to=james.bottomley@steeleye.com \
--cc=Martin.Bligh@us.ibm.com \
--cc=akpm@digeo.com \
--cc=axboe@suse.de \
--cc=dledford@redhat.com \
--cc=linux-scsi@vger.kernel.org \
--cc=pbadari@us.ibm.com \
/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