LiveActive security incident?Get immediate response
CVE Record

CVE-2021-46986: usb: dwc3: gadget: Free gadget structure only after freeing endpoints

In the Linux kernel, the following vulnerability has been resolved: usb: dwc3: gadget: Free gadget structure only after freeing endpoints As part of commit e81a7018d93a ("usb: dwc3: allocate gadget structure dynamically") the dwc3_gadget_release() was added which will free the dwc->gadget structure upon the device's removal when usb_del_gadget_udc() is called in dwc3_gadget_exit(). However, simply freeing the gadget results a dangling pointer situation: the endpoints created in dwc3_gadget_init_endpoints() have their dep->endpoint.ep_list members chained off the list_head anchored at dwc->gadget->ep_list. Thus when dwc->gadget is freed, the first dwc3_ep in the list now has a dangling prev pointer and likewise for the next pointer of the dwc3_ep at the tail of the list. The dwc3_gadget_free_endpoints() that follows will result in a use-after-free when it calls list_del(). This was caught by enabling KASAN and performing a driver unbind. The recent commit 568262bf5492 ("usb: dwc3: core: Add shutdown callback for dwc3") also exposes this as a panic during shutdown. There are a few possibilities to fix this. One could be to perform a list_del() of the gadget->ep_list itself which removes it from the rest of the dwc3_ep chain. Another approach is what this patch does, by splitting up the usb_del_gadget_udc() call into its separate "del" and "put" components. This allows dwc3_gadget_free_endpoints() to be called before the gadget is finally freed with usb_put_gadget().

UnknownCVSS not scoredNot KEV-listedUpdated
Glexia's TakeAutomated analysismoderate

Security readout for executives and security teams

Plain-English summary

This Linux kernel bug can crash affected systems during USB DWC3 gadget driver cleanup. The flaw is a memory lifetime error: kernel code frees the gadget structure before freeing endpoint list entries that still reference it. Business urgency is highest for embedded, appliance, or device fleets using USB gadget/peripheral mode.

Executive priority

Treat this as targeted operational stability risk, not broad internet-facing emergency. Patch affected device classes through normal kernel maintenance, with higher priority for products, appliances, or environments where shutdown reliability and USB gadget behavior are business-critical.

Technical view

CVE-2021-46986 is a use-after-free in the Linux USB DWC3 gadget cleanup path. After dynamic gadget allocation, dwc3_gadget_release() could free dwc->gadget while endpoints remained chained from dwc->gadget->ep_list. Subsequent dwc3_gadget_free_endpoints() calls list_del() on stale list pointers, producing a KASAN-detected UAF and possible shutdown panic.

Likely exposure

Exposure appears limited to affected Linux kernel versions and configurations using the Synopsys DWC3 USB controller in gadget/peripheral mode. The source lists Linux 5.10 through fixed stable ranges as affected. General systems without this driver path are less likely exposed, but the bundle does not provide distribution-specific package status.

Exploitation context

The bundle does not show active exploitation, and KEV is false. The issue was caught with KASAN during driver unbind, and a later shutdown callback made it visible as a panic during shutdown. Sources support crash risk, not remote exploitation or privilege escalation.

Researcher notes

The root cause is cleanup ordering around gadget and endpoint list lifetime. The upstream fix splits usb_del_gadget_udc() into delete and put phases so endpoints are freed before usb_put_gadget() releases the gadget. Evidence does not include CVSS, CWE, exploitability analysis, or distribution advisories.

Mitigation direction

  • Upgrade to a Linux kernel containing the referenced stable fixes.
  • Prioritize embedded or appliance fleets using DWC3 USB gadget mode.
  • Check Linux distribution advisories for backported kernel fixes.
  • Reduce unnecessary USB gadget exposure where operationally feasible.
  • Track reboot or shutdown panics until patched.

Validation and detection

  • Inventory Linux kernel versions against the affected and fixed ranges.
  • Confirm whether DWC3 gadget/peripheral mode is enabled on assets.
  • Review kernel logs for DWC3, gadget, unbind, shutdown, or KASAN UAF messages.
  • Verify vendor kernel packages include the referenced upstream fix.
  • Regression-test shutdown and USB gadget removal on representative hardware.
Prepared
Confidence
medium
Sources
6

Generated from the cited source records. This long-tail analysis has not been individually reviewed by a named human.

Potential ATT&CK relevance

Conservative CVE-to-ATT&CK context

These mappings and lookup hints may be relevant to the vulnerability behavior, CWE, affected product, or exposure path. Glexia-inferred context is not an official MITRE, ATT&CK, CWE, or CVE Program mapping.

ATT&CK lookup starting points

Use these exact CWE pages and searches to review the Glexia ATT&CK library from this CVE's weakness and description context.

cve · low confidence lookup

CVE-2021-46986 mapping review

Open the CVE-to-ATT&CK bridge for reviewed, inferred, or future official mappings tied to this CVE.

Open ATT&CK lookup
Vulnerability profileCVE Program record
Severity
Unknown
CVSS
Not scored
Known Exploited
No
Published
Official CVE source material

CNA and ADP enrichment extracted from CVE v5

These fields come from the CVE record and ADP containers, not from Glexia's Take. They preserve time-varying source decisions such as CISA SSVC, KEV status, CVSS metrics, and provider references.

0CVSS vectors
3Timeline events
2ADP providers
5Source links

SSVC decision data

CISA-ADPCISA Coordinator
Timestamp
Version
2.0.3
Exploitation: noneAutomatable: noTechnical Impact: partial

Vulnerability timeline

Timeline events are normalized from CVE metadata, CNA source timelines, ADP timelines, and KEV metadata when present.

  1. CVE reservedCVE Program

    The CVE ID was reserved by the assigning CNA.

  2. CVE publishedCVE Program

    The CVE record was published.

  3. CVE updatedCVE Program

    The CVE record metadata indicates this as the latest update time.

ADP provider summaries

CVECVE Program Container
CISA-ADPCISA ADP Vulnrichment
other:ssvc
Affected products

Products and packages named in the record

VendorProductVersion / packageStatus
LinuxLinuxe81a7018d93a7de31a3f121c9a7eecd0a5ec58b0, e81a7018d93a7de31a3f121c9a7eecd0a5ec58b0, e81a7018d93a7de31a3f121c9a7eecd0a5ec58b0, e81a7018d93a7de31a3f121c9a7eecd0a5ec58b0unaffected
LinuxLinux5.10, 0, 5.10.38, 5.11.22, 5.12.5, 5.13affected
Weakness

CWE details

No CWE listed

CWE links open Glexia weakness intelligence pages with official CWE context, developer remediation guidance, and related CVE mappings.