* [PATCH] bcache: fix use-after-free problem in bcache_device_free()
@ 2021-11-03 6:49 Coly Li
2021-11-03 7:21 ` Christoph Hellwig
2021-11-03 12:00 ` Jens Axboe
0 siblings, 2 replies; 3+ messages in thread
From: Coly Li @ 2021-11-03 6:49 UTC (permalink / raw)
To: linux-bcache
Cc: linux-block, Coly Li, Christoph Hellwig, Hannes Reinecke,
Ulf Hansson, stable
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@suse.de>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Cc: stable@vger.kernel.org # v5.14+
---
drivers/md/bcache/super.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index 4a9a65dff95e..86b9e355c583 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -885,9 +885,9 @@ static void bcache_device_free(struct bcache_device *d)
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);
--
2.31.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] bcache: fix use-after-free problem in bcache_device_free()
2021-11-03 6:49 [PATCH] bcache: fix use-after-free problem in bcache_device_free() Coly Li
@ 2021-11-03 7:21 ` Christoph Hellwig
2021-11-03 12:00 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2021-11-03 7:21 UTC (permalink / raw)
To: Coly Li
Cc: linux-bcache, linux-block, Christoph Hellwig, Hannes Reinecke,
Ulf Hansson, stable
Looks good,
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] bcache: fix use-after-free problem in bcache_device_free()
2021-11-03 6:49 [PATCH] bcache: fix use-after-free problem in bcache_device_free() Coly Li
2021-11-03 7:21 ` Christoph Hellwig
@ 2021-11-03 12:00 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2021-11-03 12:00 UTC (permalink / raw)
To: Coly Li, linux-bcache
Cc: stable, Hannes Reinecke, Christoph Hellwig, Ulf Hansson, linux-block
On Wed, 3 Nov 2021 14:49:17 +0800, Coly Li wrote:
> 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().
>
> [...]
Applied, thanks!
[1/1] bcache: fix use-after-free problem in bcache_device_free()
commit: 8468f45091d2866affed6f6a7aecc20779139173
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-11-03 12:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-03 6:49 [PATCH] bcache: fix use-after-free problem in bcache_device_free() Coly Li
2021-11-03 7:21 ` Christoph Hellwig
2021-11-03 12:00 ` Jens Axboe
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.