This is a note to let you know that I've just added the patch titled bcache: fix use-after-free problem in bcache_device_free() to the 5.15-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: bcache-fix-use-after-free-problem-in-bcache_device_free.patch and it can be found in the queue-5.15 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 8468f45091d2866affed6f6a7aecc20779139173 Mon Sep 17 00:00:00 2001 From: Coly Li <colyli@xxxxxxx> Date: Wed, 3 Nov 2021 14:49:17 +0800 Subject: bcache: fix use-after-free problem in bcache_device_free() From: Coly Li <colyli@xxxxxxx> commit 8468f45091d2866affed6f6a7aecc20779139173 upstream. In bcache_device_free(), pointer disk is referenced still in ida_simple_remove() after blk_cleanup_disk() gets called on this pointer. This may cause a potential panic by use-after-free on the disk pointer. This patch fixes the problem by calling blk_cleanup_disk() after ida_simple_remove(). Fixes: bc70852fd104 ("bcache: convert to blk_alloc_disk/blk_cleanup_disk") Signed-off-by: Coly Li <colyli@xxxxxxx> Cc: Christoph Hellwig <hch@xxxxxx> Cc: Hannes Reinecke <hare@xxxxxxx> Cc: Ulf Hansson <ulf.hansson@xxxxxxxxxx> Cc: stable@xxxxxxxxxxxxxxx # v5.14+ Reviewed-by: Christoph Hellwig <hch@xxxxxx> Link: https://lore.kernel.org/r/20211103064917.67383-1-colyli@xxxxxxx Signed-off-by: Jens Axboe <axboe@xxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/md/bcache/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -885,9 +885,9 @@ static void bcache_device_free(struct bc bcache_device_detach(d); if (disk) { - blk_cleanup_disk(disk); ida_simple_remove(&bcache_device_idx, first_minor_to_idx(disk->first_minor)); + blk_cleanup_disk(disk); } bioset_exit(&d->bio_split); Patches currently in stable-queue which might be from colyli@xxxxxxx are queue-5.15/bcache-fix-use-after-free-problem-in-bcache_device_free.patch queue-5.15/bcache-revert-bcache-use-bvec_virt.patch