CVE-2021-47272·Kernel vulnerability
In the Linux kernel, the following vulnerability has been resolved: usb: dwc3: gadget: Bail from dwc3_gadget_exit() if dwc->gadget is NULL There exists a possible scenario in which dwc3_gadget_init() can fail: during during host -> peripheral mode switch in dwc3_set_mode(), and a pending gadget driver fails to bind. Then, if the DRD undergoes another mode switch from peripheral->host the resulting dwc3_gadget_exit() will attempt to reference an invalid and dangling dwc->gadget pointer as well as call dma_free_coherent() on unmapped DMA pointers. The exact scenario can be reproduced as follows: - Start DWC3 in peripheral mode - Configure ConfigFS gadget with FunctionFS instance (or use g_ffs) - Run FunctionFS userspace application (open EPs, write descriptors, etc) - Bind gadget driver to DWC3's UDC - Switch DWC3 to host mode => dwc3_gadget_exit() is called. usb_del_gadget() will put the ConfigFS driver instance on the gadget_driver_pending_list - Stop FunctionFS application (closes the ep files) - Switch DWC3 to peripheral mode => dwc3_gadget_init() fails as usb_add_gadget() calls check_pending_gadget_drivers() and attempts to rebind the UDC to the ConfigFS gadget but fails with -19 (-ENODEV) because the FFS instance is not in FFS_ACTIVE state (userspace has not re-opened and written the descriptors yet, i.e. desc_ready!=0). - Switch DWC3 back to host mode => dwc3_gadget_exit() is called again, but this time dwc->gadget is invalid. Although it can be argued that userspace should take responsibility for ensuring that the FunctionFS application be ready prior to allowing the composite driver bind to the UDC, failure to do so should not result in a panic from the kernel driver. Fix this by setting dwc->gadget to NULL in the failure path of dwc3_gadget_init() and add a check to dwc3_gadget_exit() to bail out unless the gadget pointer is valid.
- Severity
- medium
- Software
- Kernel
- Fixed in
- 5.12.11
- Published
How likely is exploitation
FIRST's Exploit Prediction Scoring System puts the probability of this CVE being exploited in the next 30 days at <0.1% — higher than 5% of all published CVEs. EPSS is an independent forecast of exploitation, not a severity rating: it says nothing about how much damage a successful attack does, which is what a CVSS score measures.
Affected versions
From: 5.11
Until: 5.12.11
Fixed in: 5.12.11
How to fix this CVE
Update your Linux kernel to version 5.12.11 or later to resolve this USB DWC3 gadget mode-switching vulnerability. This patch prevents kernel panics that occur when the DWC3 controller fails to initialize in peripheral mode and subsequently switches back to host mode. Apply the kernel update through your distribution's package manager and reboot to activate the patched version.
sudo dnf check-update kernel && sudo dnf update kernelDefensia detects this vulnerability
How to check if you are affected
- Check your kernel version with: uname -r
- Identify if you are using DWC3 USB controller by running: grep -i dwc3 /proc/device-tree/usb*/compatible 2>/dev/null or lsusb -v | grep -i dwc
- Search kernel logs for DWC3-related errors during mode switches: dmesg | grep -i dwc3
- Verify the fix by confirming kernel version is >= 5.12.11 with: uname -r
FAQ
What is CVE-2021-47272?
This vulnerability allows a kernel panic when the DWC3 USB gadget driver fails during peripheral mode initialization and the device subsequently switches to host mode, causing an attempt to free invalid memory pointers.
Is CVE-2021-47272 being actively exploited?
No, this vulnerability is not listed in the CISA Known Exploited Vulnerabilities catalog and no public exploits are available. Exploitation requires specific hardware (DWC3 USB controller) and precise timing of mode switches.
What versions of Kernel are affected by CVE-2021-47272?
Kernel versions 5.11 through 5.12.10 are affected. The vulnerability was resolved in version 5.12.11 and later.
How do I check if my server is vulnerable to CVE-2021-47272?
Run 'uname -r' to check your kernel version. If the version is between 5.11 and 5.12.10 inclusive, and you have a DWC3 USB controller, you are vulnerable.
Does Defensia detect CVE-2021-47272?
Yes — Defensia's CVE advisory scanner compares installed package versions against the NVD database. If the Linux kernel is installed on a monitored server, CVE-2021-47272 will appear in your dashboard with remediation steps.
Related Kernel CVEs
References
- https://git.kernel.org/stable/c/03715ea2e3dbbc56947137ce3b4ac18a726b2f87
- https://git.kernel.org/stable/c/4aad390363d2b9b3e92428dd34d27bb7ea8f1ee8
- https://git.kernel.org/stable/c/851dee5a5da56564a70290713aee665403bb0b24
- https://git.kernel.org/stable/c/03715ea2e3dbbc56947137ce3b4ac18a726b2f87
- https://git.kernel.org/stable/c/4aad390363d2b9b3e92428dd34d27bb7ea8f1ee8
Track CVEs across your fleet automatically
Defensia scans your Linux servers and tells you exactly which ones are running vulnerable versions — including CVE-2021-47272. Free for 1 server.
Get started free