CVE-2026-31617: usb: gadget: f_ncm: validate minimum block_len in ncm_unwrap_ntb()
In the Linux kernel, the following vulnerability has been resolved:
usb: gadget: fncm: validate minimum blocklen in ncmunwrapntb()
The blocklen read from the host-supplied NTB header is checked against ntbmax but has no lower bound. When blocklen is smaller than opts->ndpsize, the bounds check of: ndpindex > (blocklen - opts->ndpsize) will underflow producing a huge unsigned value that ndpindex can never exceed, defeating the check entirely.
The same underflow occurs in the datagram index checks against blocklen - opts->dpesize. With those checks neutered, a malicious USB host can choose ndpindex and datagram offsets that point past the actual transfer, and the skbputdata() copies adjacent kernel memory into the network skb.
Fix this by rejecting block lengths that cannot hold at least the NTB header plus one NDP. This will make blocklen - opts->ndpsize and blocklen - opts->dpesize both well-defined.
Commit 8d2b1a1ec9f5 ("CDC-NCM: avoid overflow in sanity checking") fixed a related class of issues on the host side of NCM.
Affected Software
Event History
Frequently Asked Questions
Who can exploit this issue?
An attacker must act as a malicious USB host communicating with a system using the Linux kernel's USB gadget NCM function (f_ncm). The CVSS vector indicates local access and low privileges are required; no user interaction is required.
What is the impact of a successful exploit?
A malicious host can provide crafted NTB headers and offsets that cause adjacent kernel memory to be copied into a network skb. The reported CVSS impact is limited to availability, with no confidentiality or integrity impact listed.
Is a default configuration affected?
The issue is relevant when the USB gadget NCM function, f_ncm, is in use. The provided data does not establish whether that function is enabled or configured by default.
What change addresses the issue?
The fix rejects NTB block lengths too small to contain at least the NTB header and one NDP. This prevents unsigned underflow in NDP and datagram bounds checks.