From: Bart Van Assche <bvanassche@acm.org>
To: Peiyang He <peiyang_he@smail.nju.edu.cn>, axboe@kernel.dk
Cc: ming.lei@redhat.com, fengnanchang@gmail.com,
linux-block@vger.kernel.org, stable@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] blk-mq: fix null-ptr-deref in blk_mq_run_hw_queues
Date: Wed, 2 Dec 2026 09:41:37 -0800 [thread overview]
Message-ID: <480b7ac5-5a48-43f5-8ce3-1edf4289758f@acm.org> (raw)
In-Reply-To: <F5E00FBB97BC76D9+20261202151340.2228227-1-peiyang_he@smail.nju.edu.cn>
On 12/2/26 7:13 AM, Peiyang He wrote:
> A concurrent caller such as blk_mq_unquiesce_queue() can then get a
> NULL hctx from queue_hctx() and dereference hctx->state in
> blk_mq_hctx_stopped(), causing a NULL pointer dereference.
Please make it clear that this is a block layer bug and that the NBD
driver is only one way to trigger it.
> Fixes: d0c98769ee7d ("blk-mq: use array manage hctx map instead of
xarray")
This race is much older than commit d0c98769ee7d. I think this is the
proper Fixes tag:
Fixes: 868f2f0b7206 ("blk-mq: dynamic h/w context count")
> + /*
> + * __blk_mq_update_nr_hw_queues() updates nr_hw_queues and queue_hw_ctx
> + * while the queue is frozen. So we can use q_usage_counter to avoid
> + * racing with it.
> + */
> + if (!percpu_ref_tryget(&q->q_usage_counter))
> + return;
The approach looks good to me but please make the comment more explicit,
e.g. as follows:
/*
* Holding a q_usage_counter reference prevents queue freezing from
* completion and hence serializes the loop below against
* __blk_mq_update_nr_hw_queues().
*/
Thanks,
Bart.
next prev parent reply other threads:[~2026-12-02 17:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 15:13 Peiyang He
2026-12-02 17:41 ` Bart Van Assche [this message]
2026-12-02 22:48 ` Jens Axboe
2026-12-03 0:10 ` 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=480b7ac5-5a48-43f5-8ce3-1edf4289758f@acm.org \
--to=bvanassche@acm.org \
--cc=axboe@kernel.dk \
--cc=fengnanchang@gmail.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ming.lei@redhat.com \
--cc=peiyang_he@smail.nju.edu.cn \
--cc=stable@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
all inboxes | Powered by JetHome®