{"schemaVersion":1,"url":"https://cve.openhack.com/cve/CVE-2022-49398","id":"CVE-2022-49398","title":"usb: dwc3: gadget: Replace list_for_each_entry_safe() if using giveback","description":"In the Linux kernel, the following vulnerability has been resolved:\n\nusb: dwc3: gadget: Replace list_for_each_entry_safe() if using giveback\n\nThe list_for_each_entry_safe() macro saves the current item (n) and\nthe item after (n+1), so that n can be safely removed without\ncorrupting the list.  However, when traversing the list and removing\nitems using gadget giveback, the DWC3 lock is briefly relea","descriptionLong":"In the Linux kernel, the following vulnerability has been resolved:\n\nusb: dwc3: gadget: Replace list_for_each_entry_safe() if using giveback\n\nThe list_for_each_entry_safe() macro saves the current item (n) and\nthe item after (n+1), so that n can be safely removed without\ncorrupting the list.  However, when traversing the list and removing\nitems using gadget giveback, the DWC3 lock is briefly released,\nallowing other routines to execute.  There is a situation where, while\nitems are being removed from the cancelled_list using\ndwc3_gadget_ep_cleanup_cancelled_requests(), the pullup disable\nroutine is running in parallel (due to UDC unbind).  As the cleanup\nroutine removes n, and the pullup disable removes n+1, once the\ncleanup retakes the DWC3 lock, it references a request who was already\nremoved/handled.  With list debug enabled, this leads to a panic.\nEnsure all instances of the macro are replaced where gadget giveback\nis used.\n\nExample call stack:\n\nThread#1:\n__dwc3_gadget_ep_set_halt() - CLEAR HALT\n  -> dwc3_gadget_ep_cleanup_cancelled_requests()\n    ->list_for_each_entry_safe()\n    ->dwc3_gadget_giveback(n)\n      ->dwc3_gadget_del_and_unmap_request()- n deleted[cancelled_list]\n      ->spin_unlock\n      ->Thread#2 executes\n      ...\n    ->dwc3_gadget_giveback(n+1)\n      ->Already removed!\n\nThread#2:\ndwc3_gadget_pullup()\n  ->waiting for dwc3 spin_lock\n  ...\n  ->Thread#1 released lock\n  ->dwc3_stop_active_transfers()\n    ->dwc3_remove_requests()\n      ->fetches n+1 item from cancelled_list (n removed by Thread#1)\n      ->dwc3_gadget_giveback()\n        ->dwc3_gadget_del_and_unmap_request()- n+1 deleted[cancelled_list]\n        ->spin_unlock","published":"2025-02-26T02:12:27.141Z","updated":"2026-11-17T07:00:27.546379144Z","reserved":"2025-02-26T02:08:31.563Z","status":"Analyzed","rejected":false,"assigner":"Linux","metric":{"version":"3.1","score":5.5,"vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H","rating":"medium","source":"NVD"},"metrics":[{"version":"3.1","score":5.5,"vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H","rating":"medium","source":"NVD"}],"rating":"medium","products":["Linux"],"affectedProducts":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"d4f1afe5e896c18ae01099a85dab5e1a198bd2a8","lessThan":"1c6e5dc3b639c96e6839a8d1b8e951923fdfd34a","status":"affected","versionType":"git"},{"version":"d4f1afe5e896c18ae01099a85dab5e1a198bd2a8","lessThan":"2424307cdf421ac72075a1384eae4e4199ab6457","status":"affected","versionType":"git"},{"version":"d4f1afe5e896c18ae01099a85dab5e1a198bd2a8","lessThan":"26a7e6832afe9d9a991cfd9015177f083cf959cc","status":"affected","versionType":"git"},{"version":"d4f1afe5e896c18ae01099a85dab5e1a198bd2a8","lessThan":"bf594d1d0c1d7b895954018043536ffd327844f9","status":"affected","versionType":"git"},{"version":"d7ff2e3ff0e09d57b43014fe26b13bb3c9677254","status":"affected","versionType":"git"},{"version":"4.19.57","lessThan":"4.20","status":"affected","versionType":"semver"}],"platforms":[]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"5.0","status":"affected"},{"version":"0","lessThan":"5.0","status":"unaffected","versionType":"semver"},{"version":"5.15.47","lessThanOrEqual":"5.15.*","status":"unaffected","versionType":"semver"},{"version":"5.17.15","lessThanOrEqual":"5.17.*","status":"unaffected","versionType":"semver"},{"version":"5.18.4","lessThanOrEqual":"5.18.*","status":"unaffected","versionType":"semver"},{"version":"5.19","lessThanOrEqual":"*","status":"unaffected","versionType":"original_commit_for_fix"}],"platforms":[]}],"packages":[],"cwes":[],"aliases":[],"references":[{"url":"https://git.kernel.org/stable/c/1c6e5dc3b639c96e6839a8d1b8e951923fdfd34a","tags":["Patch","web"]},{"url":"https://git.kernel.org/stable/c/2424307cdf421ac72075a1384eae4e4199ab6457","tags":["Patch","web"]},{"url":"https://git.kernel.org/stable/c/26a7e6832afe9d9a991cfd9015177f083cf959cc","tags":["Patch","web"]},{"url":"https://git.kernel.org/stable/c/bf594d1d0c1d7b895954018043536ffd327844f9","tags":["Patch","web"]},{"url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2022/49xxx/CVE-2022-49398.json","tags":["advisory"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2022-49398","tags":["advisory"]},{"url":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","tags":["package"]}],"patchReferenced":true,"fixAvailable":true,"exploitReferenced":false,"kev":false,"kevAdded":null,"kevDue":null,"kevEntry":null,"ssvc":null,"epss":0.00268,"epssPercentile":0.19263,"sources":[{"name":"CVE List","url":"https://www.cve.org/CVERecord?id=CVE-2022-49398","ok":true},{"name":"NVD","url":"https://nvd.nist.gov/vuln/detail/CVE-2022-49398","ok":true,"note":"Analyzed"},{"name":"OSV","url":"https://osv.dev/vulnerability/CVE-2022-49398","ok":true,"note":"0 packages"},{"name":"CISA KEV","url":"https://www.cisa.gov/known-exploited-vulnerabilities-catalog","ok":true,"note":"not listed"},{"name":"EPSS","url":"https://api.first.org/data/v1/epss?cve=CVE-2022-49398","ok":true,"note":"scored 2026-11-19"}],"aiTitle":false,"tech":[],"critical":[],"attention":null}