CVE-2021-39685
Linux Kernel vulnerability analysis and mitigation

Overview

CVE-2021-39685 is a buffer overflow vulnerability discovered in the Linux kernel's USB Gadget subsystem. The vulnerability was identified by Szymon Heidrich and disclosed in December 2021. The issue affects various setup methods of the USB gadget subsystem, where an incorrect flag check could lead to an out-of-bounds write. The vulnerability impacts multiple USB gadget types including rndis, hid, uac1, uac1_legacy, and uac2 (Openwall).

Technical details

The vulnerability stems from improper handling of control request lengths (wLength) in USB gadget handlers. The buffer used by endpoint 0 is allocated in composite.c with a size of USBCOMPEP0BUFSIZ (4096) bytes, but the implementation fails to properly restrict the size of control requests. This allows an attacker to set wLength to a value greater than USBCOMPEP0BUFSIZ, resulting in a buffer overflow. The vulnerability has been assigned a CVSS v3.1 base score of 7.8 (High) with vector: CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H (NVD).

Impact

The vulnerability allows a local attacker to read and/or write up to 65kB of kernel memory past buffer boundaries. This can lead to information disclosure, denial of service (system crash), or potentially arbitrary code execution in kernel context. No additional execution privileges are needed, and user interaction is not required for exploitation (Openwall, Ubuntu).

Mitigation and workarounds

The vulnerability was patched by limiting the transfer phase size to min(len, buffer_size) in affected control request handlers to prevent buffer overflow. The fix was merged into the main Linux kernel tree on December 12, 2021. Various Linux distributions have released security updates to address this vulnerability, including Ubuntu which has provided fixes for multiple kernel versions across different releases (Ubuntu).

Additional resources


SourceThis report was generated using AI

Related Linux Kernel vulnerabilities:

CVE ID

Severity

Score

Technologies

Component name

CISA KEV exploit

Has fix

Published date

CVE-2025-40258HIGH7
  • Linux KernelLinux Kernel
  • kernel-zfcpdump-devel-matched
NoNoDec 04, 2025
CVE-2025-40259MEDIUM6.2
  • Linux KernelLinux Kernel
  • kernel-64k-devel
NoNoDec 04, 2025
CVE-2025-40264MEDIUM5.5
  • Linux KernelLinux Kernel
  • kernel-rt-64k-debug-kvm
NoNoDec 04, 2025
CVE-2025-40254MEDIUM5.5
  • Linux KernelLinux Kernel
  • kernel-modules-partner
NoNoDec 04, 2025
CVE-2025-40253MEDIUM5.5
  • Linux KernelLinux Kernel
  • python3-perf
NoNoDec 04, 2025

Free Vulnerability Assessment

Benchmark your Cloud Security Posture

Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.

Request assessment

Get a personalized demo

Ready to see Wiz in action?

"Best User Experience I have ever seen, provides full visibility to cloud workloads."
David EstlickCISO
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
Adam FletcherChief Security Officer
"We know that if Wiz identifies something as critical, it actually is."
Greg PoniatowskiHead of Threat and Vulnerability Management