Linux block layer
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Ming Lei <ming.lei@redhat.com>, Bart Van Assche <bart.vanassche@wdc.com>
Cc: linux-block@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
	Joseph Qi <joseph.qi@linux.alibaba.com>
Subject: Re: [PATCH] blk-mq: Avoid that submitting a bio concurrently with device removal triggers a crash
Date: Tue, 10 Apr 2018 20:10:26 -0600	[thread overview]
Message-ID: <81efe671-59ef-3a4b-b941-f1c5d2c18915@kernel.dk> (raw)
In-Reply-To: <20180411020541.GB4494@ming.t460p>

On 4/10/18 8:05 PM, Ming Lei wrote:
> On Tue, Apr 10, 2018 at 02:30:35PM -0600, Bart Van Assche wrote:
>> Because blkcg_exit_queue() is now called from inside blk_cleanup_queue()
>> it is no longer safe to access cgroup information during or after the
>> blk_cleanup_queue() call. Hence protect the generic_make_request_checks()
>> call with blk_queue_enter() / blk_queue_exit().
>>
>> Reported-by: Ming Lei <ming.lei@redhat.com>
>> Fixes: a063057d7c73 ("block: Fix a race between request queue removal and the block cgroup controller")
>> Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
>> Cc: Ming Lei <ming.lei@redhat.com>
>> Cc: Joseph Qi <joseph.qi@linux.alibaba.com>
>> ---
>>  block/blk-core.c | 32 ++++++++++++++++++++++++++------
>>  1 file changed, 26 insertions(+), 6 deletions(-)
>>
>> diff --git a/block/blk-core.c b/block/blk-core.c
>> index 34e2f2227fd9..a330cd2829e1 100644
>> --- a/block/blk-core.c
>> +++ b/block/blk-core.c
>> @@ -2386,8 +2386,19 @@ blk_qc_t generic_make_request(struct bio *bio)
>>  	 * yet.
>>  	 */
>>  	struct bio_list bio_list_on_stack[2];
>> +	blk_mq_req_flags_t flags = bio->bi_opf & REQ_NOWAIT ?
>> +		BLK_MQ_REQ_NOWAIT : 0;
>> +	struct request_queue *q = bio->bi_disk->queue;
>>  	blk_qc_t ret = BLK_QC_T_NONE;
>>  
>> +	if (blk_queue_enter(q, flags) < 0) {
> 
> As I mentioned last time, the queue pointer has to be checked before
> calling blk_queue_enter(), since it isn't difficult to trigger the
> failure log of 'generic_make_request: Trying to access nonexistent
> block-device'.

That's a good point, the NULL check needs to be included first. Bart,
do you want to send an update? I can just rebase the for-linus branch.

-- 
Jens Axboe

  reply	other threads:[~2018-04-11  2:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-10 20:30 [PATCH] blk-mq: Avoid that submitting a bio concurrently with device removal triggers a crash Bart Van Assche
2018-04-11  2:05 ` Ming Lei
2018-04-11  2:10   ` Jens Axboe [this message]
2018-04-11  2:26     ` 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=81efe671-59ef-3a4b-b941-f1c5d2c18915@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=bart.vanassche@wdc.com \
    --cc=hch@lst.de \
    --cc=joseph.qi@linux.alibaba.com \
    --cc=linux-block@vger.kernel.org \
    --cc=ming.lei@redhat.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