Linux block layer
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Christoph Hellwig <hch@lst.de>
Cc: kbusch@kernel.org, linux-block@vger.kernel.org
Subject: Re: [PATCH] blk-mq: always take a queue reference in blk_mq_submit_bio
Date: Thu, 21 May 2026 09:12:05 -0600	[thread overview]
Message-ID: <89c94510-abb6-485c-87c4-73364c8f6914@kernel.dk> (raw)
In-Reply-To: <20260520084905.1092158-1-hch@lst.de>

On 5/20/26 2:49 AM, Christoph Hellwig wrote:
> When submitting a bio to blk-mq, if the task should sleep after peeking
> a cached request, but before it pops it, the plug flushes and calls
> blk_mq_free_plug_rqs, freeing the cached_rqs. This creates a
> use-after-free bug.
> 
> Fix this by alway grabbing a queue usage reference in blk_mq_submit_bio.
> While past commit claims that this is slow, we're better safe than
> fast as a first priority.
> 
> The code had already warned of this possibility, and specifically popped
> the request before other known blocking calls, but it didn't handle a
> blocking GFP_NOIO alloc. Under memory pressure, allocating the split bio
> or the integrity payload are two such cases that can block. The blk-mq
> submit_bio function continues using the peeked request that was already
> freed and re-initialized, so the driver receives that request with a
> NULL'ed mq_hctx, and inevitably panics.
> 
> Large parts of the commit message are stolen from an earlier attempt
> to fix this issue by Keith Busch <kbusch@kernel.org>.

This is about a 5% regression in peak performance, fwiw. I'm all for
eliminating this issue, but this kind of big hammer approach is pretty
crap in terms of adding overhead to the IO path. Maybe we just cover
blocking split bio case, and look into doing a proper fix for 7.2 that
isn't such a massive regression?

-- 
Jens Axboe

  parent reply	other threads:[~2026-05-21 15:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-20  8:49 [PATCH] blk-mq: always take a queue reference in blk_mq_submit_bio Christoph Hellwig
2026-05-20 14:59 ` Keith Busch
2026-05-21 15:12 ` Jens Axboe [this message]
2026-05-22  8:56   ` Christoph Hellwig

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=89c94510-abb6-485c-87c4-73364c8f6914@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=linux-block@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