In the Linux kernel, the following vulnerability has been resolved:
block/rqqos: protect rqqos apis with a new lock
commit 50e34d78815e ("block: disable the elevator int delgendisk") move rqqosexit() from diskrelease() to del_gendisk(), this will introduce some problems:
1) If rqqosadd() is triggered by enabling iocost/iolatency through cgroupfs, then it can concurrent with delgendisk(), it's not safe to write 'q->rqqos' concurrently.
2) Activate cgroup policy that is relied on rqqos will call rqqosadd() and blkcgactivatepolicy(), and if rqqosexit() is called in the middle, null-ptr-dereference will be triggered in blkcgactivate_policy().
3) blkgconfopenbdev() can call blkdevgetnoopen() first to find the disk, then if rqqosexit() from delgendisk() is done before rqqos_add(), then memory will be leaked.
This patch add a new disk level mutex 'rqqosmutex':
1) The lock will protect rqqosexit() directly.
2) For wbt that doesn't relied on blk-cgroup, rqqosadd() can only be called from disk initialization for now because wbt can't be destructed until rqqosexit(), so it's safe not to protect wbt for now. Hoever, in case that rqqos dynamically destruction is supported in the furture, this patch also protect rqqosadd() from wbtinit() directly, this is enough because blk-sysfs already synchronize writers with disk removal.
3) For iocost and iolatency, in order to synchronize disk removal and cgroup configuration, the lock is held after blkdevgetnoopen() from blkgconfopenbdev(), and is released in blkgconfexit(). In order to fix the above memory leak, disk_live() is checked after holding the new lock.
{
"cna_assigner": "Linux",
"osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2023/53xxx/CVE-2023-53823.json"
}