From: Chao Shi <coshi036@gmail.com>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@kernel.org>, Weidong Zhu <weizhu@fiu.edu>
Subject: [PATCH 6.6.y] block: skip sync_blockdev() on surprise removal in bdev_mark_dead()
Date: Thu, 16 Jul 2026 03:34:52 -0400 [thread overview]
Message-ID: <20260716073452.3246468-1-coshi036@gmail.com> (raw)
In-Reply-To: <2026071548-remember-handling-8672@gregkh>
commit 49f06cff50a4ccf3b7a1a662ceb892b3b21a527a upstream.
bdev_mark_dead()'s @surprise == true means the device is already gone.
The filesystem callback fs_bdev_mark_dead() honours this and skips
sync_filesystem(), but the bare block device path (no ->mark_dead op)
lost its !surprise guard when the holder ->mark_dead callback was wired
up (see Fixes), and now calls sync_blockdev() unconditionally, which can
hang forever waiting on writeback that can no longer complete.
syzkaller hit this via nvme_reset_work()'s "I/O queues lost" path:
nvme_mark_namespaces_dead() -> blk_mark_disk_dead() ->
bdev_mark_dead(bdev, true) -> sync_blockdev() blocks in
folio_wait_writeback(), wedging the reset worker and every task waiting
on it.
Skip the sync on surprise removal, matching fs_bdev_mark_dead();
invalidate_bdev() still runs. Orderly removal (surprise == false) is
unchanged.
Found by FuzzNvme.
Fixes: d8530de5a6e8 ("block: call into the file system for bdev_mark_dead")
Acked-by: Sungwoo Kim <iam@sung-woo.kim>
Acked-by: Dave Tian <daveti@purdue.edu>
Acked-by: Weidong Zhu <weizhu@fiu.edu>
Signed-off-by: Chao Shi <coshi036@gmail.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Link: https://patch.msgid.link/20260522220025.1770388-1-coshi036@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
[ adjusted for 6.6.y: bdev_mark_dead() there still unlocks bd_holder_lock
after the if/else and the else arm is a bare sync_blockdev(), so the
!surprise guard is added as "else if (!surprise)" instead of inside the
mainline else block. ]
Signed-off-by: Chao Shi <coshi036@gmail.com>
---
block/bdev.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/block/bdev.c b/block/bdev.c
index f3b13aa1b7d4..2bbe0408dac2 100644
--- a/block/bdev.c
+++ b/block/bdev.c
@@ -961,7 +961,12 @@ void bdev_mark_dead(struct block_device *bdev, bool surprise)
mutex_lock(&bdev->bd_holder_lock);
if (bdev->bd_holder_ops && bdev->bd_holder_ops->mark_dead)
bdev->bd_holder_ops->mark_dead(bdev, surprise);
- else
+ /*
+ * On surprise removal the device is already gone; syncing is
+ * futile and can hang forever waiting on I/O that will never
+ * complete. Match fs_bdev_mark_dead(), which also skips it.
+ */
+ else if (!surprise)
sync_blockdev(bdev);
mutex_unlock(&bdev->bd_holder_lock);
--
2.43.0
next prev parent reply other threads:[~2026-07-16 7:34 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-14 21:20 Please backport 49f06cff50a4 ("block: skip sync_blockdev() on surprise removal in bdev_mark_dead()") to 6.6.y, 6.12.y, 6.18.y Chao S
2026-07-15 4:48 ` Greg KH
2026-07-15 7:46 ` Chao S
2026-07-16 7:34 ` Chao Shi [this message]
2026-07-17 1:37 ` [PATCH 6.6.y] block: skip sync_blockdev() on surprise removal in bdev_mark_dead() Sasha Levin
2026-07-18 2:54 ` Chao S
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=20260716073452.3246468-1-coshi036@gmail.com \
--to=coshi036@gmail.com \
--cc=gregkh@kernel.org \
--cc=stable@vger.kernel.org \
--cc=weizhu@fiu.edu \
/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