CVE-2022-50704

Source
https://cve.org/CVERecord?id=CVE-2022-50704
Import Source
https://storage.googleapis.com/osv-test-cve-osv-conversion/osv-output/CVE-2022-50704.json
JSON Data
https://api.test.osv.dev/v1/vulns/CVE-2022-50704
Downstream
Related
Published
2025-12-24T10:55:19.295Z
Modified
2026-03-20T12:22:36.852320Z
Summary
USB: gadget: Fix use-after-free during usb config switch
Details

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

USB: gadget: Fix use-after-free during usb config switch

In the process of switching USB config from rndis to other config, if the hardware does not support the ->pullup callback, or the hardware encounters a low probability fault, both of them may cause the ->pullup callback to fail, which will then cause a system panic (use after free).

The gadget drivers sometimes need to be unloaded regardless of the hardware's behavior.

Analysis as follows:

(1) write /config/usb_gadget/g1/UDC "none"

getherdisconnect+0x2c/0x1f8 rndisdisable+0x4c/0x74 compositedisconnect+0x74/0xb0 configfscompositedisconnect+0x60/0x7c usbgadgetdisconnect+0x70/0x124 usbgadgetunregisterdriver+0xc8/0x1d8 gadgetdevdescUDCstore+0xec/0x1e4

(2) rm /config/usb_gadget/g1/configs/b.1/f1

rndisderegister+0x28/0x54 rndisfree+0x44/0x7c usbputfunction+0x14/0x1c configusbcfgunlink+0xc4/0xe0 configfsunlink+0x124/0x1c8 vfs_unlink+0x114/0x1dc

(3) rmdir /config/usb_gadget/g1/functions/rndis.gs4

panic+0x1fc/0x3d0 dopagefault+0xa8/0x46c domemabort+0x3c/0xac el1synchandler+0x40/0x78 0xffffff801138f880 rndisclose+0x28/0x34 ethstop+0x74/0x110 devclosemany+0x48/0x194 rollbackregisteredmany+0x118/0x814 unregisternetdev+0x20/0x30 gethercleanup+0x1c/0x38 rndisattrrelease+0xc/0x14 krefput+0x74/0xb8 configfsrmdir+0x314/0x374

If gadget->ops->pullup() return an error, function rndis_close() will be

called, then it will causes a use-after-free problem.

Database specific
{
    "osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2022/50xxx/CVE-2022-50704.json",
    "cna_assigner": "Linux"
}
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
0a55187a1ec8c03d0619e7ce41d10fdc39cff036
Fixed
30e926aa835ac2e6ad05822e4cb75833feb0d99f
Fixed
99a58ac42d9b6911834b0224b6782aea0c311346
Fixed
afdc12887f2b2ecf20d065a7d81ad29824155083

Database specific

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

Linux / Kernel

Package

Name
Kernel

Affected ranges

Type
ECOSYSTEM
Events
Introduced
4.20.0
Fixed
6.0.16
Type
ECOSYSTEM
Events
Introduced
6.1.0
Fixed
6.1.2

Database specific

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