Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

bcache: fix uninitialized closure object

In the previous patch ("bcache: fix cached_dev.sb_bio use-after-free and
crash"), we adopted a simple modification suggestion from AI to fix the
use-after-free.

But in actual testing, we found an extreme case where the device is
stopped before calling bch_write_bdev_super().

At this point, struct closure sb_write has not been initialized yet.
For this patch, we ensure that sb_bio has been completed via
sb_write_mutex.

Signed-off-by: Mingzhe Zou <mingzhe.zou@easystack.cn>
Signed-off-by: Coly Li <colyli@fnnas.com>
Link: https://patch.msgid.link/20260403042135.2221247-1-colyli@fnnas.com
Fixes: fec114a98b87 ("bcache: fix cached_dev.sb_bio use-after-free and crash")
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Mingzhe Zou and committed by
Jens Axboe
20a8e451 fec114a9

+2 -1
+2 -1
drivers/md/bcache/super.c
··· 1378 1378 * The sb_bio is embedded in struct cached_dev, so we must 1379 1379 * ensure no I/O is in progress. 1380 1380 */ 1381 - closure_sync(&dc->sb_write); 1381 + down(&dc->sb_write_mutex); 1382 + up(&dc->sb_write_mutex); 1382 1383 1383 1384 if (dc->sb_disk) 1384 1385 folio_put(virt_to_folio(dc->sb_disk));