gpiolib: cdev: fix NULL-pointer dereferences
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
| No fix yet |
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
| No fix yet |
| Linux Linux |
|
|
In the Linux kernel, the following vulnerability has been resolved:
gpiolib: cdev: fix NULL-pointer dereferences
There are several places where we can crash the kernel by requesting lines, unbinding the GPIO device, then calling any of the system calls relevant to the GPIO character device's annonymous file descriptors: ioctl(), read(), poll().
While I observed it with the GPIO simulator, it will also happen for any of the GPIO devices that can be hot-unplugged - for instance any HID GPIO expander (e.g. CP2112).
This affects both v1 and v2 uAPI.
This fixes it partially by checking if gdev->chip is not NULL but it doesn't entirely remedy the situation as we still have a race condition in which another thread can remove the device after the check.
From the CVE record · Linux
The Linux kernel GPIO character device can dereference a NULL pointer when a GPIO device is unbound after its lines are requested. A local user able to perform that sequence can crash the kernel by calling ioctl(), read(), or poll() on the resulting file descriptor. Both v1 and v2 GPIO interfaces are affected.
Engineers running Linux kernels with GPIO devices that can be unbound or hot-unplugged should check their systems; affected versions were not provided.