usb: cdns3: gadget: Use-after-free during failed initialization and exit of cdnsp gadget
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
≥ 8bc1901ca7b07d864fca11461b3875b31f949765 · < 87c5ff5615dc0a37167e8faf3adeeddc6f1344a3| No fix yet |
| Linux Linux |
|
|
In the Linux kernel, the following vulnerability has been resolved:
usb: cdns3: gadget: Use-after-free during failed initialization and exit of cdnsp gadget
In the __cdnsp_gadget_init() and cdnsp_gadget_exit() functions, the gadget structure (pdev->gadget) was freed before its endpoints. The endpoints are linked via the ep_list in the gadget structure. Freeing the gadget first leaves dangling pointers in the endpoint list. When the endpoints are subsequently freed, this results in a use-after-free.
Fix: By separating the usb_del_gadget_udc() operation into distinct "del" and "put" steps, cdnsp_gadget_free_endpoints() can be executed prior to the final release of the gadget structure with usb_put_gadget().
A patch similar to bb9c74a5bd14("usb: dwc3: gadget: Free gadget structure only after freeing endpoints").
From the CVE record · Linux
The Linux kernel’s cdnsp gadget code can use freed memory when initialization fails or the gadget exits, because it frees the gadget structure before its endpoints. The input does not specify how an attacker could trigger this condition or whether access or user interaction is required.
Engineers running Linux kernels with the cdnsp gadget code should check their versions; affected versions are not specified.