CVE-2023-54087: ubi: Fix possible null-ptr-deref in ubi_free_volume()
From: Greg Kroah-Hartman <[email protected]>
Description
===========
In the Linux kernel, the following vulnerability has been resolved:
ubi: Fix possible null-ptr-deref in ubi_free_volume()
It willl cause null-ptr-deref in the following case:
uif_init()
ubi_add_volume()
cdev_add() -> if it fails, call kill_volumes()
device_register()kill_volumes() -> if ubi_add_volume() fails call this function
ubi_free_volume()
cdev_del()
device_unregister() -> trying to delete a not added device,
it causes null-ptr-derefSo in ubi_free_volume(), it delete devices whether they are added or not, it will causes null-ptr-deref.
Handle the error case whlie calling ubi_add_volume() to fix this problem. If add volume fails, set the corresponding vol to null, so it can not be accessed in kill_volumes() and release the resource in ubi_add_volume() error path.
The Linux kernel CVE team has assigned CVE-2023-54087 to this issue.
Affected and fixed versions
===========================
Issue introduced in 2.6.22 with commit 801c135ce73d5df1caf3eca35b66a10824ae0707 and fixed in 4.14.308 with commit 5558bcf1c58720ca6e9d6198d921cb3aa337f038 Issue introduced in 2.6.22 with commit 801c135ce73d5df1caf3eca35b66a10824ae0707 and fixed in 4.19.276 with commit 45b2c5ca4d2edae70f19fdb086bd927840c4c309 Issue introduced in 2.6.22 with commit 801c135ce73d5df1caf3eca35b66a10824ae0707 and fixed in 5.4.235 with commit 234c53e57424992e657e6f4acc00d3df0983176f Issue introduced in 2.6.22 with commit 801c135ce73d5df1caf3eca35b66a10824ae0707 and fixed in 5.10.173 with commit fcbc795abe7897da4b5d2a6ab5010e36774b00c2 Issue introduced in 2.6.22 with commit 801c135ce73d5df1caf3eca35b66a10824ae0707 and fixed in 5.15.100 with commit 5ec4c8aca5a221756a9007deadfea92795319fee Issue introduced in 2.6.22 with commit 801c135ce73d5df1caf3eca35b66a10824ae0707 and fixed in 6.1.18 with commit 2ea7195b195009ecf0046e55361f393ba96d02db Issue introduced in 2.6.22 with commit 801c135ce73d5df1caf3eca35b66a10824ae0707 and fixed in 6.2.5 with commit 9eccdb0760cbcb4427b5303a83a3007de998af51 Issue introduced in 2.6.22 with commit 801c135ce73d5df1caf3eca35b66a10824ae0707 and fixed in 6.3 with commit c15859bfd326c10230f09cb48a17f8a35f190342
Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community.
Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at
https://cve.org/CVERecord/?id=CVE-2023-54087
will be updated if fixes are backported, please check that for the most up to date information about this issue.
Affected files
==============
The file(s) affected by this issue are:
drivers/mtd/ubi/build.c
drivers/mtd/ubi/vmt.c
Mitigation
==========
The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits:
https://git.kernel.org/stable/c/5558bcf1c58720ca6e9d6198d921cb3aa337f038 https://git.kernel.org/stable/c/45b2c5ca4d2edae70f19fdb086bd927840c4c309 https://git.kernel.org/stable/c/234c53e57424992e657e6f4acc00d3df0983176f https://git.kernel.org/stable/c/fcbc795abe7897da4b5d2a6ab5010e36774b00c2 https://git.kernel.org/stable/c/5ec4c8aca5a221756a9007deadfea92795319fee https://git.kernel.org/stable/c/2ea7195b195009ecf0046e55361f393ba96d02db https://git.kernel.org/stable/c/9eccdb0760cbcb4427b5303a83a3007de998af51 https://git.kernel.org/stable/c/c15859bfd326c10230f09cb48a17f8a35f190342