mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "yukuai (C)" <yukuai3@huawei.com>
To: Ming Lei <ming.lei@redhat.com>
Cc: <axboe@kernel.dk>, <linux-block@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <yi.zhang@huawei.com>
Subject: Re: [PATCH RFC] blk-mq: fix potential uaf for 'queue_hw_ctx'
Date: Thu, 24 Feb 2022 10:43:20 +0800	[thread overview]
Message-ID: <430683f5-d271-b2f2-8f7c-486e2a4a7d42@huawei.com> (raw)
In-Reply-To: <YhbqWqtwNueSffuR@T590>

在 2022/02/24 10:15, Ming Lei 写道:
>> Hi, Ming
>>
>> If blk_mq_quiesce_queue() is called from __blk_mq_update_nr_hw_queues()
>> first, and then swithing elevator to none won't trigger the problem.
>> However, what if blk_mq_unquiesce_queue() from switching elevator
>> decrease quiesce_depth to 0 first, and then blk_mq_quiesce_queue() is
>> called from __blk_mq_update_nr_hw_queues(), it seems to me such
>> concurrent scenarios still exist.
> 
> No, the scenario won't exist, once blk_mq_quiesce_queue() returns, it is
> guaranteed that:
> 
> - in-progress run queue is drained
> - no new run queue can be started

I understand that... What I mean about the concurrent scenario is that
reading queue_hw_ctx in blk_mq_run_hw_queues(), not the actual run
queue blk_mq_run_hw_queue():

t1                              t2
elevator_switch
  blk_mq_quiesce_queue -> quiesce_depth = 1
  blk_mq_unquiesce_queue-> quiesce_depth = 0
   blk_mq_run_hw_queues
                                  __blk_mq_update_nr_hw_queues
                                   blk_mq_quiesce_queue
    queue_for_each_hw_ctx
    -> quiesce_queue can't prevent reading queue_hw_ctx
     blk_mq_run_hw_queue
     //need_run is always false, nothing to do

Am I missing something about blk_mq_quiesce_queue ?

Thanks,
Kuai

  reply	other threads:[~2022-02-24  2:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-23 11:26 Yu Kuai
2022-02-23 14:30 ` Ming Lei
2022-02-24  1:29   ` yukuai (C)
2022-02-24  2:15     ` Ming Lei
2022-02-24  2:43       ` yukuai (C) [this message]
2022-02-25  2:40 ` Ming Lei
2022-02-25  3:15   ` yukuai (C)

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=430683f5-d271-b2f2-8f7c-486e2a4a7d42@huawei.com \
    --to=yukuai3@huawei.com \
    --cc=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ming.lei@redhat.com \
    --cc=yi.zhang@huawei.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

all inboxes | Powered by JetHome®