CVE-2023-54321: driver core: fix potential null-ptr-deref in device_add()
In the Linux kernel, the following vulnerability has been resolved:
driver core: fix potential null-ptr-deref in deviceadd()
I got the following null-ptr-deref report while doing fault injection test:
BUG: kernel NULL pointer dereference, address: 0000000000000058 CPU: 2 PID: 278 Comm: 37-i2c-ds2482 Tainted: G B W N 6.1.0-rc3+ RIP: 0010:klistput+0x2d/0xd0 Call Trace: <TASK> klistremove+0xf1/0x1c0 devicereleasedriverinternal+0x196/0x210 busremovedevice+0x1bd/0x240 deviceadd+0xd3d/0x1100 w1addmasterdevice+0x476/0x490 [wire] ds2482probe+0x303/0x3e0 [ds2482]
This is how it happened:
w1allocdev() // The dev->driver is set to w1masterdriver. memcpy(&dev->dev, device, sizeof(struct device)); deviceadd() busadddevice() dpmsysfsadd() // It fails, calls busremovedevice.
// error path busremovedevice() // The dev->driver is not null, but driver is not bound. devicereleasedriver() klistremove(&dev->p->knodedriver) <-- It causes null-ptr-deref.
// normal path busprobedevice() // It's not called yet. devicebinddriver()
If dev->driver is set, in the error path after calling busadddevice() in deviceadd(), busremovedevice() is called, then the device will be detached from driver. But devicebinddriver() is not called yet, so it causes null-ptr-deref while access the 'knodedriver'. To fix this, set dev->driver to null in the error path before calling busremovedevice().
Affected Software
Remediation
Event History
Frequently Asked Questions
What is the severity of CVE-2023-54321?
CVE-2023-54321 has a medium severity due to the potential for a kernel NULL pointer dereference.
How do I fix CVE-2023-54321?
To fix CVE-2023-54321, update your Linux kernel to a version later than 6.1.0-rc3 where the vulnerability has been patched.
What systems are affected by CVE-2023-54321?
CVE-2023-54321 affects versions of the Linux kernel prior to the patch including 6.1.0-rc3.
What is the impact of CVE-2023-54321?
The impact of CVE-2023-54321 could lead to a denial of service due to unexpected kernel crashes.
Is there a workaround for CVE-2023-54321?
There is no known workaround for CVE-2023-54321, so applying the kernel update is recommended.