CVE-2026-139099: net: bgmac: fix TX DMA unmapping and slot cleanup
In the Linux kernel, the following vulnerability has been resolved:
net: bgmac: fix TX DMA unmapping and slot cleanup
When mapping a fragment fails, bgmacdmatxadd() unwinds with the wrong slots. It passes the failed fragment's slot->dmaaddr, which holds the mapping error, to dmaunmapsingle() 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 dmaaddr cleared either, which includes the head slot when mapping the head fails.
bgmacdmatxringfree() unmaps every slot with a non-zero dmaaddr, so tearing down the ring unmaps these addresses again. It also frees the skbs of pending TX slots but leaves slot->skb and slot->dmaaddr set. The slots survive a down/up cycle, and bgmacdmatxadd() 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, bgmacdmatxfree() frees the old skb a second time when that slot completes.
bgmacdmatxringfree() also picks dmaunmapsingle() or dmaunmappage() by looking at slot->skb, which is set on the last slot of a packet, while the head was mapped with dmamapsingle() and the fragments with skbfragdmamap().
In the error path, unmap the head and each mapped fragment from their own slots, and clear dmaaddr on every slot the failed packet touched. In bgmacdmatxringfree(), choose the unmap function by the SOF flag of the descriptor like bgmacdmatxfree() 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.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Compensating control
In bgmac_dma_tx_ring_free(), choose dma_unmap_single() or dma_unmap_page() using the SOF flag. In the mapping-error path, unmap the head and each mapped fragment with the matching unmap function, process fragment slots starting at ring->end + 1, and clear dma_addr and skb on every slot touched. When freeing pending TX slots, clear both fields.