gpio: sysfs: fix chip removal with GPIOs exported over sysfs
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
| No fix yet |
| Linux Linux |
|
|
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
| No fix yet |
| Linux Linux |
|
|
6.18.166.19.67.0In the Linux kernel, the following vulnerability has been resolved:
gpio: sysfs: fix chip removal with GPIOs exported over sysfs
Currently if we export a GPIO over sysfs and unbind the parent GPIO controller, the exported attribute will remain under /sys/class/gpio because once we remove the parent device, we can no longer associate the descriptor with it in gpiod_unexport() and never drop the final reference.
Rework the teardown code: provide an unlocked variant of gpiod_unexport() and remove all exported GPIOs with the sysfs_lock taken before unregistering the parent device itself. This is done to prevent any new exports happening before we unregister the device completely.
From the CVE record · Linux
The Linux kernel can leave an exported GPIO attribute under /sys/class/gpio when its parent GPIO controller is unbound. This requires a GPIO to be exported through sysfs before the controller is unbound; the input does not specify an attacker role or authentication requirements.
Engineers running Linux kernels that export GPIOs through sysfs should check whether their kernel is affected; no affected versions are listed.