CVE-2022-49398

Source
https://cve.org/CVERecord?id=CVE-2022-49398
Import Source
https://storage.googleapis.com/osv-test-cve-osv-conversion/osv-output/CVE-2022-49398.json
JSON Data
https://api.test.osv.dev/v1/vulns/CVE-2022-49398
Downstream
Related
Published
2025-02-26T02:12:27.141Z
Modified
2026-03-20T12:24:28.734037Z
Summary
usb: dwc3: gadget: Replace list_for_each_entry_safe() if using giveback
Details

In the Linux kernel, the following vulnerability has been resolved:

usb: dwc3: gadget: Replace listforeachentrysafe() if using giveback

The listforeachentrysafe() macro saves the current item (n) and the item after (n+1), so that n can be safely removed without corrupting the list. However, when traversing the list and removing items using gadget giveback, the DWC3 lock is briefly released, allowing other routines to execute. There is a situation where, while items are being removed from the cancelledlist using dwc3gadgetepcleanupcancelledrequests(), the pullup disable routine is running in parallel (due to UDC unbind). As the cleanup routine removes n, and the pullup disable removes n+1, once the cleanup retakes the DWC3 lock, it references a request who was already removed/handled. With list debug enabled, this leads to a panic. Ensure all instances of the macro are replaced where gadget giveback is used.

Example call stack:

Thread#1: __dwc3gadgetepsethalt() - CLEAR HALT -> dwc3gadgetepcleanupcancelledrequests() ->listforeachentrysafe() ->dwc3gadgetgiveback(n) ->dwc3gadgetdelandunmaprequest()- n deleted[cancelledlist] ->spinunlock ->Thread#2 executes ... ->dwc3gadgetgiveback(n+1) ->Already removed!

Thread#2: dwc3gadgetpullup() ->waiting for dwc3 spinlock ... ->Thread#1 released lock ->dwc3stopactivetransfers() ->dwc3removerequests() ->fetches n+1 item from cancelledlist (n removed by Thread#1) ->dwc3gadgetgiveback() ->dwc3gadgetdelandunmaprequest()- n+1 deleted[cancelledlist] ->spinunlock

Database specific
{
    "cna_assigner": "Linux",
    "osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2022/49xxx/CVE-2022-49398.json"
}
References

Affected packages

Git / git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git

Affected ranges

Type
GIT
Repo
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
Events
Introduced
d4f1afe5e896c18ae01099a85dab5e1a198bd2a8
Fixed
1c6e5dc3b639c96e6839a8d1b8e951923fdfd34a
Fixed
2424307cdf421ac72075a1384eae4e4199ab6457
Fixed
26a7e6832afe9d9a991cfd9015177f083cf959cc
Fixed
bf594d1d0c1d7b895954018043536ffd327844f9
Type
GIT
Repo
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
Events
Introduced
0 Unknown introduced commit / All previous commits are affected
Last affected
d7ff2e3ff0e09d57b43014fe26b13bb3c9677254

Database specific

source
"https://storage.googleapis.com/osv-test-cve-osv-conversion/osv-output/CVE-2022-49398.json"