В ядре Linux была устранена следующая уязвимость: net: spacemit: clear TX descriptor on fragment mapping failure emac_tx_mem_map() пишет TX_DESC_0_OWN в дескриптор кольца для каждого слота за пределами old_head, как только локальная копия этого слота memset()'d будет совершена с "*tx_desc_addr tx_desc", т.е. Если emac_tx_map_frag() затем терпит неудачу на более позднем фрагменте, путь err_free_skb вызывает emac_free_tx_buf() для снятия карты и удаления skb, но оставляет уже написанную память дескриптора нетронутой, и tx_ring->head никогда не продвигается мимо old_head (хранилище «tx_ring->head head» пропускает goto). Таким образом, слот между old_head и откатной головкой можно оставить с набором TX_DESC_0_OWN и buffer_addr_{1,2, указывая на отображения DMA, которые emac_free_tx_buf () просто разорвал, в то время как программное обеспечение считает этот слот бесплатным снова.
Следующий успешный вызов emac_tx_mem_map() перестраивает только сам old_head; если движок DMA автоматически продвигается в следующий дескриптор, как только он закончит пакет old_head's, он получит этот устаревший, уже не отображенный адрес. emac_tx_clean_desc() уже обрабатывает emac_free_tx_buf() и очищает дескриптор как пару при восстановлении завершенных дескрипторов; сделайте то же в пути отобрания.
Показать оригинальное описание (EN)
In the Linux kernel, the following vulnerability has been resolved: net: spacemit: clear TX descriptor on fragment mapping failure emac_tx_mem_map() writes TX_DESC_0_OWN into the ring descriptor for every slot beyond old_head as soon as that slot's memset()'d local copy is committed with "*tx_desc_addr = tx_desc", i.e. before the buffers for that slot have necessarily all been mapped successfully. If emac_tx_map_frag() then fails on a later fragment, the err_free_skb path calls emac_free_tx_buf() to unmap and drop the skb, but leaves the already-written descriptor memory untouched, and tx_ring->head is never advanced past old_head (the "tx_ring->head = head" store is skipped by the goto). So a slot between old_head and the rolled-back head can be left with TX_DESC_0_OWN set and buffer_addr_{1,2} pointing at DMA mappings that emac_free_tx_buf() just tore down, while software considers that slot free again. The next successful emac_tx_mem_map() call only rebuilds old_head itself; if the DMA engine auto-advances into the following descriptor once it finishes old_head's packet, it will fetch that stale, already-unmapped address. emac_tx_clean_desc() already treats emac_free_tx_buf() and clearing the descriptor as a pair when reclaiming completed descriptors; do the same in the mapping failure path.