All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] block: skip sync_blockdev() on surprise removal in bdev_mark_dead()
@ 2026-05-22 22:00 Chao Shi
  2026-05-25  5:58 ` Christoph Hellwig
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Chao Shi @ 2026-05-22 22:00 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Christoph Hellwig, Christian Brauner, Josef Bacik, linux-block,
	linux-kernel, Chao Shi, Sungwoo Kim, Dave Tian, Weidong Zhu

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.

Fixes: d8530de5a6e8 ("block: call into the file system for bdev_mark_dead")
Found by FuzzNvme(Syzkaller with FEMU fuzzing framework).
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>
---
 block/bdev.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/block/bdev.c b/block/bdev.c
index b8fbb9576110..7fc3f5ba22a3 100644
--- a/block/bdev.c
+++ b/block/bdev.c
@@ -1259,7 +1259,13 @@ void bdev_mark_dead(struct block_device *bdev, bool surprise)
 		bdev->bd_holder_ops->mark_dead(bdev, surprise);
 	else {
 		mutex_unlock(&bdev->bd_holder_lock);
-		sync_blockdev(bdev);
+		/*
+		 * 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.
+		 */
+		if (!surprise)
+			sync_blockdev(bdev);
 	}
 
 	invalidate_bdev(bdev);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] block: skip sync_blockdev() on surprise removal in bdev_mark_dead()
  2026-05-22 22:00 [PATCH] block: skip sync_blockdev() on surprise removal in bdev_mark_dead() Chao Shi
@ 2026-05-25  5:58 ` Christoph Hellwig
  2026-05-26 18:01   ` Chao S
  2026-05-26 16:37 ` Jens Axboe
  2026-05-27 12:02 ` Christian Brauner
  2 siblings, 1 reply; 6+ messages in thread
From: Christoph Hellwig @ 2026-05-25  5:58 UTC (permalink / raw)
  To: Chao Shi
  Cc: Jens Axboe, Christoph Hellwig, Christian Brauner, Josef Bacik,
	linux-block, linux-kernel, Sungwoo Kim, Dave Tian, Weidong Zhu

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] block: skip sync_blockdev() on surprise removal in bdev_mark_dead()
  2026-05-22 22:00 [PATCH] block: skip sync_blockdev() on surprise removal in bdev_mark_dead() Chao Shi
  2026-05-25  5:58 ` Christoph Hellwig
@ 2026-05-26 16:37 ` Jens Axboe
  2026-05-26 18:02   ` Chao S
  2026-05-27 12:02 ` Christian Brauner
  2 siblings, 1 reply; 6+ messages in thread
From: Jens Axboe @ 2026-05-26 16:37 UTC (permalink / raw)
  To: Chao Shi
  Cc: Christoph Hellwig, Christian Brauner, Josef Bacik, linux-block,
	linux-kernel, Sungwoo Kim, Dave Tian, Weidong Zhu


On Fri, 22 May 2026 18:00:25 -0400, Chao Shi wrote:
> 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.
> 
> [...]

Applied, thanks!

[1/1] block: skip sync_blockdev() on surprise removal in bdev_mark_dead()
      commit: 304f384f34af98a205086ce67331cad4fea6504d

Best regards,
-- 
Jens Axboe




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] block: skip sync_blockdev() on surprise removal in bdev_mark_dead()
  2026-05-25  5:58 ` Christoph Hellwig
@ 2026-05-26 18:01   ` Chao S
  0 siblings, 0 replies; 6+ messages in thread
From: Chao S @ 2026-05-26 18:01 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Jens Axboe, Christian Brauner, Josef Bacik, linux-block,
	linux-kernel, Sungwoo Kim, Dave Tian, Weidong Zhu

Thanks for your kindly review!.

Best,
Chao

On Mon, May 25, 2026 at 1:58 AM Christoph Hellwig <hch@lst.de> wrote:
>
> Looks good:
>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] block: skip sync_blockdev() on surprise removal in bdev_mark_dead()
  2026-05-26 16:37 ` Jens Axboe
@ 2026-05-26 18:02   ` Chao S
  0 siblings, 0 replies; 6+ messages in thread
From: Chao S @ 2026-05-26 18:02 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Christoph Hellwig, Christian Brauner, Josef Bacik, linux-block,
	linux-kernel, Sungwoo Kim, Dave Tian, Weidong Zhu

Thanks Jens! I appreciate your work!.

Best,
Chao

On Tue, May 26, 2026 at 12:37 PM Jens Axboe <axboe@kernel.dk> wrote:
>
>
> On Fri, 22 May 2026 18:00:25 -0400, Chao Shi wrote:
> > 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.
> >
> > [...]
>
> Applied, thanks!
>
> [1/1] block: skip sync_blockdev() on surprise removal in bdev_mark_dead()
>       commit: 304f384f34af98a205086ce67331cad4fea6504d
>
> Best regards,
> --
> Jens Axboe
>
>
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] block: skip sync_blockdev() on surprise removal in bdev_mark_dead()
  2026-05-22 22:00 [PATCH] block: skip sync_blockdev() on surprise removal in bdev_mark_dead() Chao Shi
  2026-05-25  5:58 ` Christoph Hellwig
  2026-05-26 16:37 ` Jens Axboe
@ 2026-05-27 12:02 ` Christian Brauner
  2 siblings, 0 replies; 6+ messages in thread
From: Christian Brauner @ 2026-05-27 12:02 UTC (permalink / raw)
  To: Chao Shi
  Cc: Jens Axboe, Christoph Hellwig, Josef Bacik, linux-block,
	linux-kernel, Sungwoo Kim, Dave Tian, Weidong Zhu

On Fri, May 22, 2026 at 06:00:25PM -0400, Chao Shi wrote:
> 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.
> 
> Fixes: d8530de5a6e8 ("block: call into the file system for bdev_mark_dead")
> Found by FuzzNvme(Syzkaller with FEMU fuzzing framework).
> 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: Christian Brauner <brauner@kernel.org>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-05-27 12:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-22 22:00 [PATCH] block: skip sync_blockdev() on surprise removal in bdev_mark_dead() Chao Shi
2026-05-25  5:58 ` Christoph Hellwig
2026-05-26 18:01   ` Chao S
2026-05-26 16:37 ` Jens Axboe
2026-05-26 18:02   ` Chao S
2026-05-27 12:02 ` Christian Brauner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.