From: Md Haris Iqbal <haris.iqbal@linux.dev>
To: Jens Axboe <axboe@kernel.dk>, linux-block@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
Jonathan Corbet <corbet@lwn.net>,
linux-doc@vger.kernel.org, Md Haris Iqbal <haris.iqbal@linux.dev>,
Sashiko <sashiko-bot@kernel.org>
Subject: [PATCH for-rc 1/3] block: fail a delayed bio if its disk was removed
Date: Sat, 5 Dec 2026 15:19:10 +0100 [thread overview]
Message-ID: <20261205141912.37608-2-haris.iqbal@linux.dev> (raw)
In-Reply-To: <20261205141912.37608-1-haris.iqbal@linux.dev>
A bio delayed by an error injection rule is resubmitted from a workqueue
with submit_bio_noacct_nocheck(), which skips bio_check_eod(). The
delayed bio holds no queue usage counter, so del_gendisk() does not wait
for it. For disks that don't own their queue, such as sd and sr, the
queue is unfrozen again after del_gendisk(). When sd is unbound while a
bio is delayed, the resubmitted bio reaches scsi_queue_rq() after the
driver is gone:
BUG: kernel NULL pointer dereference, address: 00000000000000c0
Workqueue: blk_error_inject blk_error_inject_delay_work
RIP: 0010:scsi_queue_rq+0x5b2/0xb80
Call Trace:
__blk_mq_issue_directly+0x3f/0xb0
blk_mq_try_issue_directly+0x8e/0x110
blk_mq_submit_bio+0x6b0/0x710
submit_bio_noacct_nocheck+0x2da/0x3c0
process_one_work+0x19b/0x370
Fail the bio instead of resubmitting it if the disk is dead. Rules
that fail the bio after the delay then also end it with BLK_STS_IOERR.
Fixes: 6bd856cc9996 ("block: allow error injection rules to delay bios")
Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/patchset/20261111215838.103356-1-haris.iqbal%40linux.dev?part=2
Signed-off-by: Md Haris Iqbal <haris.iqbal@linux.dev>
---
block/error-injection.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/block/error-injection.c b/block/error-injection.c
index a6de52229ef3..88544eb41c08 100644
--- a/block/error-injection.c
+++ b/block/error-injection.c
@@ -66,6 +66,12 @@ static void blk_error_inject_delay_work(struct work_struct *work)
kfree(d);
+ /* the disk was removed while the bio was delayed */
+ if (test_bit(GD_DEAD, &bio->bi_bdev->bd_disk->state)) {
+ bio_io_error(bio);
+ return;
+ }
+
if (status != BLK_STS_OK) {
blk_error_inject_fail(bio, status);
return;
--
2.53.0
next prev parent reply other threads:[~2026-12-05 14:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-05 14:19 [PATCH for-rc 0/3] block: error injection delay fixes Md Haris Iqbal
2026-12-05 14:19 ` Md Haris Iqbal [this message]
2026-12-05 14:19 ` [PATCH for-rc 2/3] block: clear BIO_ERROR_INJECTED when a bio changes device Md Haris Iqbal
2026-12-05 14:19 ` [PATCH for-rc 3/3] block: copy BIO_ERROR_INJECTED to the split in bio_split() Md Haris Iqbal
2026-12-05 14:33 ` [PATCH for-rc 0/3] block: error injection delay fixes Jens Axboe
-- strict thread matches above, loose matches on Subject: below --
2026-12-05 12:55 Md Haris Iqbal
2026-12-05 12:55 ` [PATCH for-rc 1/3] block: fail a delayed bio if its disk was removed Md Haris Iqbal
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=20261205141912.37608-2-haris.iqbal@linux.dev \
--to=haris.iqbal@linux.dev \
--cc=axboe@kernel.dk \
--cc=corbet@lwn.net \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sashiko-bot@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