Skip to main content
Vulnerability Database/CVE-2024-26996

CVE-2024-26996: Linux Kernel USB Gadget Use-After-Free

CVE-2024-26996 is a use-after-free flaw in Linux Kernel USB gadget f_ncm driver that occurs during interface rebinding after transport errors. This article covers technical details, affected versions, and patches.

Published:

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

CVE-2024-26996 Overview

CVE-2024-26996 is a use-after-free vulnerability [CWE-416] in the Linux kernel's USB gadget NCM (Network Control Model) function driver (f_ncm). The flaw occurs when a USB endpoint transport error happens during usb_ep_enable() while bringing down the usb0 interface. The sequence leaves dev->port_usb pointing to a freed ncm object. After a subsequent rebind, eth_start_xmit() can dereference the stale pointer, triggering kernel memory corruption. The issue affects Linux kernel versions through 6.9-rc4 and was resolved by checking ncm->netdev in ncm_disable() to properly invoke gether_disconnect().

Critical Impact

A local attacker with the ability to trigger USB gadget rebinding can cause kernel memory corruption, leading to privilege escalation or denial of service.

Affected Products

  • Linux Kernel (multiple branches prior to patched commits)
  • Linux Kernel 6.9-rc1 through 6.9-rc4
  • Fedora distributions shipping affected kernel builds

Discovery Timeline

  • 2024-05-01 - CVE-2024-26996 published to NVD
  • 2026-08-04 - Last updated in NVD database

Technical Details for CVE-2024-26996

Vulnerability Analysis

The vulnerability resides in drivers/usb/gadget/function/f_ncm.c within the Linux kernel's USB gadget subsystem. The NCM function driver manages Ethernet-over-USB connections through the gether layer, which binds a network device (usb0) to USB endpoints.

When the usb0 interface is brought down, eth_stop() is invoked. If usb_ep_enable() fails during this sequence, the in_ep or out_ep endpoints remain unenabled. The subsequent call to ncm_disable() historically checked ncm->port.in_ep->enabled before calling gether_disconnect(). Because the endpoint was never enabled, the disconnect path was skipped, leaving dev->port_usb pointing at the ncm object.

ncm_unbind() and ncm_free() then release the ncm object. When the function is rebound through configfs, a new ncm object is allocated, but usb0 still references the freed memory. Once eth_start_xmit() executes dev->wrap(), the kernel dereferences the dangling pointer and faults at an address such as dead00000000014f.

Root Cause

The root cause is incorrect state tracking in the NCM disable path. The driver conflated endpoint enablement state with gether connection state. The endpoint enable flag can be false while a gether connection is logically established, breaking the invariant that governs object lifetime.

Attack Vector

Exploitation requires local access to manipulate the USB gadget configuration through configfs. An attacker with sufficient privileges to link and unlink NCM function instances can race USB endpoint failures to trigger the use-after-free. Successful exploitation corrupts kernel memory and can escalate to arbitrary code execution in kernel context.

No exploitation code is publicly available for this issue. The vulnerability requires precise timing to induce the usb_ep_enable() error path on hardware that supports USB gadget mode.

Detection Methods for CVE-2024-26996

Indicators of Compromise

  • Kernel oops or panic messages referencing eth_start_xmit, ncm_disable, or paging requests to poisoned addresses such as dead00000000014f
  • Unexpected usb0 interface state transitions logged alongside USB endpoint errors in dmesg
  • Repeated configfs link/unlink operations against NCM gadget functions from non-administrative workflows

Detection Strategies

  • Audit kernel versions across Linux endpoints and servers to identify builds predating the fix commits listed in the kernel.org advisories
  • Monitor kernel ring buffer output for USB gadget error patterns combined with slab allocator warnings consistent with use-after-free
  • Correlate configfs filesystem writes under /sys/kernel/config/usb_gadget/ with system instability events

Monitoring Recommendations

  • Enable KASAN (Kernel Address Sanitizer) in test environments to surface use-after-free conditions during QA
  • Collect auditd records for syscalls that modify USB gadget configfs entries
  • Centralize kernel crash dumps and dmesg output in a SIEM for correlation across fleet systems

How to Mitigate CVE-2024-26996

Immediate Actions Required

  • Apply the upstream kernel patches referenced by commits 0588bbbd718a, 6334b8e4553c, 7250326cbb1f, 7f67c2020cb0, and f356fd0cbd9c from kernel.org
  • Update Fedora systems using the vendor package announcements published on the Fedora package-announce mailing list
  • Restrict access to USB gadget configfs to trusted administrators only on devices that expose gadget mode

Patch Information

The fix modifies ncm_disable() to check whether ncm->netdev is non-NULL before calling gether_disconnect(). This ensures the gether layer is torn down whenever a connection was logically established, regardless of USB endpoint enablement state. Patched commits are available at the Linux kernel stable tree. Fedora users should consult the Fedora Package Announcement for distribution-specific updates.

Workarounds

  • Disable the NCM USB gadget function on systems that do not require USB networking by removing the usb_f_ncm kernel module
  • Prevent unprivileged users from mounting or writing to configfs by tightening filesystem permissions on /sys/kernel/config
  • Where feasible, disable USB gadget mode in bootloader or device-tree configuration until patched kernels are deployed

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.