usb: gadget: f_ncm: validate datagram bounds in ncm_unwrap_ntb()
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
≥ 2b74b0a04d3e9f9f08ff026e5663dce88ff94e52 · < 40c706a0224bde194667e3378c689b542fec4b44| No fix yet |
| Linux Linux |
|
|
In the Linux kernel, the following vulnerability has been resolved:
usb: gadget: f_ncm: validate datagram bounds in ncm_unwrap_ntb()
When unpacking host-supplied NTBs, ncm_unwrap_ntb() checks datagram length against frame_max but does not verify that the datagram fits within the declared block length. Additionally, when decoding multiple NTBs from a single socket buffer, subsequent block lengths are not checked against the actual remaining buffer data.
With these checks missing, a malicious USB host can specify datagram offsets and lengths that point beyond the block, or supply secondary NTB headers declaring lengths larger than the buffer. skb_put_data() then copies adjacent kernel memory from skb_shared_info into the network skb.
Fix this by verifying that sufficient buffer space remains for the NTB header before parsing, handling zero-length block declarations, ensuring that block lengths never exceed the remaining buffer space, and verifying that each datagram payload stays strictly within the block boundary.
From the CVE record · Linux
The Linux kernel’s USB NCM gadget function fails to validate datagram and block lengths in host-supplied NTBs. A malicious USB host can use crafted NTBs to cause adjacent kernel memory to be copied into a network buffer.
Engineers running Linux systems that use the USB NCM gadget function should check their kernel versions.