usb: typec: ucsi: ccg: Fix use-after-free of ucsi on remove
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
≥ e32fd989ac1c45f993fbe89ad0a89aa9ea6993d2 · < f5c772b76bbd95de8be51cf849c6098f6af6fcf9| No fix yet |
| Linux Linux |
|
|
In the Linux kernel, the following vulnerability has been resolved:
usb: typec: ucsi: ccg: Fix use-after-free of ucsi on remove
The threaded IRQ handler ccg_irq_handler() calls ucsi_notify_common(), which on a connector-change event calls ucsi_connector_change() and schedules connector work. In ucsi_ccg_remove(), ucsi_destroy() frees uc->ucsi (kfree) before free_irq() is called, so a handler invocation already in flight may access the freed object after ucsi_destroy().
CPU 0 (remove) | CPU 1 (threaded IRQ) ucsi_destroy(uc->ucsi) | ccg_irq_handler() kfree(ucsi) // FREE | ucsi_notify_common(uc->ucsi) // USE
Move free_irq() before ucsi_destroy() in the remove path. It is kept after ucsi_unregister(): ucsi_unregister() cancels connector work whose handler issues GET_CONNECTOR_STATUS through ucsi_send_command_common(), which waits for a completion that is signalled from the IRQ handler, so the IRQ must stay active until that work has been cancelled.
The probe error path already orders free_irq() before ucsi_destroy().
This bug was found by static analysis.
From the CVE record · Linux
The Linux kernel’s USB Type-C UCSI CCG driver can access freed memory if a threaded IRQ handler is still running when the driver is removed. This is a use-after-free; the input does not establish an attacker-controlled trigger, authentication requirement, or user-interaction requirement.
Engineers running Linux kernels with the USB Type-C UCSI CCG driver should check their versions; affected versions were not provided.