From: Mike Christie <michaelc@cs.wisc.edu>
To: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: Bart Van Assche <bvanassche@acm.org>,
linux-scsi <linux-scsi@vger.kernel.org>,
Jens Axboe <axboe@kernel.dk>, Tejun Heo <tj@kernel.org>,
Jun'ichi Nomura <j-nomura@ce.jp.nec.com>,
Stefan Richter <stefanr@s5r6.in-berlin.de>
Subject: Re: [PATCH 2/4] scsi: Fix device removal NULL pointer dereference
Date: Mon, 25 Jun 2012 17:05:45 -0500 [thread overview]
Message-ID: <4FE8E0B9.8050202@cs.wisc.edu> (raw)
In-Reply-To: <1340658889.2980.51.camel@dabdike.int.hansenpartnership.com>
On 06/25/2012 04:14 PM, James Bottomley wrote:
> On Mon, 2012-06-25 at 18:15 +0000, Bart Van Assche wrote:
>> Since scsi_prep_fn() may be invoked concurrently with
>> __scsi_remove_device(), keep the queuedata pointer in
>> __scsi_remove_device(). This patch fixes a kernel oops that
>> can be triggered by USB device removal. See also
>> http://www.spinics.net/lists/linux-scsi/msg56254.html.
>
> This patch causes a subtle change of semantics: you're substituting our
> signal for dead queue as !sdev with a check of blk_queue_dead().
>
>> Reported-by: Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
>> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
>> Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
>> Cc: James Bottomley <JBottomley@parallels.com>
>> Cc: Stefan Richter <stefanr@s5r6.in-berlin.de>
>> Cc: <stable@kernel.org>
>> ---
>> drivers/scsi/hosts.c | 8 +++++++-
>> drivers/scsi/scsi_lib.c | 35 ++++++++---------------------------
>> drivers/scsi/scsi_priv.h | 1 -
>> drivers/scsi/scsi_sysfs.c | 5 +----
>> 4 files changed, 16 insertions(+), 33 deletions(-)
>>
>> diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
>> index a3a056a..6b9d89a 100644
>> --- a/drivers/scsi/hosts.c
>> +++ b/drivers/scsi/hosts.c
>> @@ -299,9 +299,15 @@ static void scsi_host_dev_release(struct device *dev)
>> destroy_workqueue(shost->work_q);
>> q = shost->uspace_req_q;
>> if (q) {
>> + /*
>> + * Note: freeing queuedata before invoking blk_cleanup_queue()
>> + * is safe here because no request function is associated with
>> + * uspace_req_q. See also the __scsi_alloc_queue() call in
>> + * drivers/scsi/scsi_tgt_lib.c.
>> + */
>
> This comment doesn't really make a whole lot of sense. What I think
> it's saying is that it's OK for the commands executed by the drain in
> blk_cleanup_queue to have a NULL queuedata and by the time we reach
> this, there can be no concurrent racing calls to queuecommand? Is this
> true, and why?
Only the scsi_tgt_lib.c code uses the uses the uspace_req_q. That code
does not use it in a traditional way. It passes __scsi_alloc_queue NULL
for the request_fn function argument, so this request queue does not
have a function that pulls requests off a queue like is done for the
initiator path.
That target code mostly uses the queue struct so that it can use the
block/scsi functions that need a request queue to build scatterlists,
cmds, bios, etc. When that code was made originally we were going to use
the queue in a more tradition way or break out the queue limits into
another struct and pass them around. I think we have the latter now, but
the target code has not been converted.
But so that is why we cannot hit a race like you are thinking about in
the initiator path.
It is also a weird use of the queue so it is also why it does not make
sense :)
next prev parent reply other threads:[~2012-06-25 22:05 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-25 18:12 [PATCH 0/4 v9] SCSI device removal fixes Bart Van Assche
2012-06-25 18:14 ` [PATCH 1/4] block: Fix blk_execute_rq_nowait() dead queue handling Bart Van Assche
2012-06-25 18:41 ` Tejun Heo
2012-06-25 19:18 ` Muthu Kumar
2012-06-25 18:15 ` [PATCH 2/4] scsi: Fix device removal NULL pointer dereference Bart Van Assche
2012-06-25 20:36 ` Tejun Heo
2012-06-25 21:14 ` James Bottomley
2012-06-25 21:21 ` Tejun Heo
2012-06-25 21:35 ` James Bottomley
2012-06-26 7:02 ` Bart Van Assche
2012-06-25 22:05 ` Mike Christie [this message]
2012-06-26 7:19 ` James Bottomley
2012-06-26 7:26 ` Bart Van Assche
2012-06-26 6:46 ` Bart Van Assche
2012-06-26 7:25 ` James Bottomley
2012-06-26 10:00 ` Bart Van Assche
2012-06-26 9:13 ` Mike Christie
2012-06-26 10:03 ` Bart Van Assche
2012-06-26 15:03 ` Hannes Reinecke
2012-06-25 18:16 ` [PATCH 3/4] scsi: Change return type of scsi_queue_insert() into void Bart Van Assche
2012-06-25 18:17 ` [PATCH 4/4] scsi: Stop accepting SCSI requests before removing a device Bart Van Assche
2012-06-25 20:42 ` Tejun Heo
-- strict thread matches above, loose matches on Subject: below --
2012-06-07 18:39 [PATCH 0/4 v8] Fixes for SCSI device removal Bart Van Assche
2012-06-07 18:43 ` [PATCH 2/4] scsi: Fix device removal NULL pointer dereference Bart Van Assche
2012-06-05 17:08 [PATCH 0/4 v7] Fixes for SCSI device removal Bart Van Assche
2012-06-05 17:11 ` [PATCH 2/4] scsi: Fix device removal NULL pointer dereference Bart Van Assche
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=4FE8E0B9.8050202@cs.wisc.edu \
--to=michaelc@cs.wisc.edu \
--cc=James.Bottomley@HansenPartnership.com \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=j-nomura@ce.jp.nec.com \
--cc=linux-scsi@vger.kernel.org \
--cc=stefanr@s5r6.in-berlin.de \
--cc=tj@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.