CVE-2026-139099 — Linux Kernel — NONE Vulnerability
In the Linux kernel, the following vulnerability has been resolved: net: bgmac: fix TX DMA unmapping and slot cleanup When mapping a fragment fails, bgmac_dma_tx_add() unwinds with the wrong slots. It passes the failed fragment's slot->dma_addr, which holds the mapping error, to dma_unmap_single() for the head. The fragment loop indexes from ring->end instead of ring->end + 1, so it unmaps the head a second time as a page and leaves the last mapped fragment mapped. None of the affected slots get their dma_addr cleared either, which includes the head slot when mapping the head fails. bgmac_dma_tx_ring_free() unmaps every slot with a non-zero dma_addr, so tearing down the ring unmaps these addresses again. It also frees the skbs of pending TX slots but leaves slot->skb and slot->dma_addr set. The slots survive a down/up cycle, and bgmac_dma_tx_add() only sets slot->skb on the last slot of a packet. If a slot with a stale pointer is later used for the head or a fragment of a scatter/gather packet, bgmac_dma_tx_free() frees the old skb a second time when that slot completes. bgmac_dma_tx_ring_free() also picks dma_unmap_single() or dma_unmap_page() by looking at slot->skb, which is set on the last slot of a packet, while the head was mapped with dma_map_single() and the fragments with skb_frag_dma_map(). In the error path, unmap the head and each mapped fragment from their own slots, and clear dma_addr on every slot the failed packet touched. In bgmac_dma_tx_ring_free(), choose the unmap function by the SOF flag of the descriptor like bgmac_dma_tx_free() does, unmap every slot before freeing any skb, since a packet can wrap around the end of the ring with its skb on the last slot, and clear both fields. This was found through code inspection by an LLM while hitting other bugs on an Asus RT-N16. It did not hit these ones specifically.
In the Linux kernel, the following vulnerability has been resolved: net: bgmac: fix TX DMA unmapping and slot cleanup When mapping a fragment fails, bgmac_dma_tx_add() unwinds with the wrong slots. It passes the failed fragment's slot->dma_addr, which holds the mapping error, to dma_unmap_single() for the head. The fragment loop indexes from ring->end instead of ring->end + 1, so it unmaps the head a second time as a page and leaves the last mapped fragment mapped. None of the affected slots get their dma_addr cleared either, which includes the head slot when mapping the head fails. bgmac_dma_tx_ring_free() unmaps every slot with a non-zero dma_addr, so tearing down the ring unmaps these addresses again. It also frees the skbs of pending TX slots but leaves slot->skb and slot->dma_addr set. The slots survive a down/up cycle, and bgmac_dma_tx_add() only sets slot->skb on the last slot of a packet. If a slot with a stale pointer is later used for the head or a fragment of a scatter/gather packet, bgmac_dma_tx_free() frees the old skb a second time when that slot completes. bgmac_dma_tx_ring_free() also picks dma_unmap_single() or dma_unmap_page() by looking at slot->skb, which is set on the last slot of a packet, while the head was mapped with dma_map_single() and the fragments with skb_frag_dma_map(). In the error path, unmap the head and each mapped fragment from their own slots, and clear dma_addr on every slot the failed packet touched. In bgmac_dma_tx_ring_free(), choose the unmap function by the SOF flag of the descriptor like bgmac_dma_tx_free() does, unmap every slot before freeing any skb, since a packet can wrap around the end of the ring with its skb on the last slot, and clear both fields. This was found through code inspection by an LLM while hitting other bugs on an Asus RT-N16. It did not hit these ones specifically.
🎯 What is this vulnerability?
This vulnerability is a complex Use-After-Free (UAF) and Double Free bug located in the bgmac (Broadcom BCM53xx) Ethernet driver within the Linux kernel. It specifically affects the Transmission (TX) DMA ring buffer management logic.
The core technical flaws are:
1. Incorrect DMA Unmapping in Error Path: When bgmac_dma_tx_add() fails to map a network fragment (scatter/gather packet), the error handling code incorrectly calls dma_unmap_single() on the head slot using the error address from the failed fragment. Furthermore, the loop that unmaps previously mapped fragments starts at the wrong index (ring->end instead of ring->end + 1), causing the head packet to be unmapped twice (once as a single buffer, once as a page) and leaving the last successfully mapped fragment mapped. Crucially, the dma_addr fields in the ring slots are not cleared after these failed operations.
2. Stale Pointer/Address Cleanup Failure: bgmac_dma_tx_ring_free() (called during device teardown or ring reset) unmaps any slot with a non-zero dma_addr. Because the error path failed to clear dma_addr, this function will attempt to unmap addresses that were already unmapped (or never validly mapped), leading to DMA mapping corruption.
3. Double Free of SKB: The ring slots retain stale skb pointers after bgmac_dma_tx_ring_free() frees the socket buffers but fails to set slot->skb to NULL. If the ring is reused (e.g., after a link down/up cycle), and a new packet is transmitted using a slot that still holds a stale skb pointer, bgmac_dma_tx_free() will attempt to free the old skb again when the new transmission completes. This results in a Double Free of the socket buffer.
4. Incorrect Unmap Function Selection: bgmac_dma_tx_ring_free() selects between dma_unmap_single() and dma_unmap_page() based on the presence of an skb in the slot. However, the head of a packet is always mapped with dma_map_single(), while fragments are mapped with skb_frag_dma_map() (which may use page mapping). The logic incorrectly assumes the last slot (which holds the skb) dictates the unmap type for all slots, leading to mismatched DMA unmap calls.
CWE Classification:
- CWE-416: Use After Free (Stale
skbpointer leading to double free) - CWE-415: Double Free (Explicit double free of
skb) - CWE-665: Improper Initialization (Failure to clear
dma_addrandskbpointers in error paths) - Target Identification: Identify devices running Linux with the
bgmacdriver loaded.
* Command: - Version Check: Determine the kernel version. The fix is in the
bgmacdriver. Checkuname -r. - Prerequisites: The attacker needs the ability to send network traffic that triggers a DMA mapping failure. This could be achieved by: * Sending malformed or oversized packets that cause the driver to attempt to map fragments that fail (e.g., due to memory pressure or specific hardware limitations). * Triggering a link down/up cycle to force
CVSS Note: The provided CVSS score is 0/10 (NONE). This is highly unusual for a kernel memory corruption bug. It likely indicates that the NVD or the source of this data has not yet assigned a proper score, or it is classified as "None" due to the specific context (e.g., requiring physical access or specific hardware not widely deployed in critical infrastructure). However, from a technical standpoint, a kernel double-free/UAF is typically rated High or Critical if exploitable.
⚡ Attack Chain
Important Context: The bgmac driver is used in embedded Broadcom-based devices (e.g., Asus RT-N16, various IoT routers, industrial controllers). Exploitation requires the ability to trigger the specific error path in bgmac_dma_tx_add() and then reuse the ring buffer.
1. Discovery & Reconnaissance
lspci | grep -i eth or dmesg | grep bgmac
* Common devices: Asus RT-N16, RT-N14U, and other Broadcom BCM53xx-based routers.
bgmac_dma_tx_ring_free() to be called while stale pointers exist.2. Exploitation
The exploitation is complex and requires precise timing and state manipulation. A realistic PoC would involve:1. Triggering the Error Path:
* Craft a scatter/gather packet (multiple fragments) where the mapping of a subsequent fragment fails. This can be simulated by exhausting DMA memory or sending a packet with a fragment that the hardware cannot map (e.g., non-contiguous physical memory that the DMA engine rejects).
* This causes bgmac_dma_tx_add() to enter the error path, leaving dma_addr set in slots and skb pointers stale.
2. Forcing Ring Reuse:
* Trigger a link down/up cycle (e.g., by unplugging/replugging the Ethernet cable or using ip link set eth0 down/up).
* This calls bgmac_dma_tx_ring_free(), which unmaps the stale dma_addr values (causing DMA corruption) but leaves slot->skb pointers intact.
3. Triggering Double Free:
* Send a new packet that uses the same ring slots.
* When the new packet completes transmission, bgmac_dma_tx_free() is called.
* It sees the stale skb pointer in the slot and attempts to free it again, resulting in a Double Free.
Illustrative PoC (Conceptual):
# 1. Identify the interface
IFACE="eth0"
# 2. Trigger DMA mapping failure (requires specific conditions, e.g., memory pressure)
# This is highly dependent on the specific hardware and kernel configuration.
# A common method is to send a large number of fragmented packets rapidly.
for i in {1..10000}; do
# Send a packet with multiple fragments (e.g., using scapy or a custom tool)
# This is illustrative; actual payload depends on the driver's fragment handling.
python3 -c "
from scapy.all import *
pkt = Ether()/IP()/UDP()/Raw(load=b'A'*1000)
sendp(pkt, iface='$IFACE', count=1)
"
done
# 3. Trigger ring reset
ip link set $IFACE down
ip link set $IFACE up
# 4. Send a new packet to trigger the double free
python3 -c "
from scapy.all import *
pkt = Ether()/IP()/UDP()/Raw(load=b'B'*100)
sendp(pkt, iface='$IFACE', count=1)
"Note: This PoC is illustrative and may not work on all systems. The actual trigger for the DMA mapping failure is hardware-specific and may require more sophisticated manipulation (e.g., using mmap to create non-contiguous memory regions or exploiting specific DMA engine limitations).
3. Post-Exploitation
🌍 Real World Impact
Practical Consequences:
bgmac is used in ICS devices, a crash could have significant operational and safety implications.🛡️ Remediation & Mitigation
Exact Affected Versions
bgmac driver prior to the commit that fixes the TX DMA unmapping and slot cleanup.Upgrade Recommendation
Actionable Workarounds
1. Disable thebgmac Driver (if possible):
* If the device has an alternative network interface (e.g., USB Ethernet), disable the bgmac interface.
* Command: ip link set eth0 down
2. Restrict Network Access:
* Limit access to the vulnerable interface to trusted networks only.
* Use firewall rules to block untrusted traffic from reaching the device.
3. Monitor for Crashes:
* Enable kernel logging and monitor for oops or panic messages related to bgmac or DMA.Detection
BUG: KASAN: double-free in bgmac_dma_tx_free
* DMA-API: device driver has busy DMA memory
* Kernel panic - not syncing: Fatal exception
⚠️ Urgency
CVSS Score: 0/10 (NONE) – Note: This is likely a placeholder or error. A kernel double-free/UAF is typically rated High or Critical.*
* If the device is internet-facing or in a critical infrastructure role, patch immediately.
* If the device is isolated, patch during the next maintenance window.
* Given the potential for ACE, treat this as a high-priority issue for any device using the
bgmac driver.[🤖 CVE Professor AI Security Engine]
FOFA Query