blk-cgroup: fix use-after-free in blkg_conf_open_bdev
Subsystems (4)
PATCH 1/1 blk-cgroup: fix use-after-free in blkg_conf_open_bdev
blkg_conf_open_bdev() holds rq_qos_mutex while checking whether the disk is still live. On the dead-disk error path, it drops the bdev reference before unlocking the mutex.
Once that reference is dropped, a concurrent put_disk() can release the remaining device reference and free the bdev. The subsequent mutex_unlock() then dereferences bdev->bd_queue from the freed object.
Unlock rq_qos_mutex while the local bdev reference still pins the object. Drop the reference only after the final bdev access.
Fixes a13bd91be223 ("block/rq_qos: protect rq_qos apis with a new lock")
Signed-off-by Shuangpeng Bai <[email protected]>
--- block/blk-cgroup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/blk-cgroup.c +1 -1
@@ -799,8 +799,8 @@ int blkg_conf_open_bdev(struct blkg_conf_ctx *ctx)mutex_lock (&bdev->bd_queue->rq_qos_mutex);if (!disk_live (bdev->bd_disk)) { -blkdev_put_no_open (bdev);mutex_unlock (&bdev->bd_queue->rq_qos_mutex); +blkdev_put_no_open (bdev);return -ENODEV ; }
Signature · 1 line
2.43.0