wifi: mt76: npu: fix RX packet reassembly across NAPI polls
Subsystems (2)
Lorenzo Bianconi
maintainerPATCH 1/1 wifi: mt76: npu: fix RX packet reassembly across NAPI polls
mt76_npu_dequeue() builds an skb from the descriptors that make up a single NPU RX packet. When a packet spans multiple descriptors and not all of them are ready yet, the function frees the partially built skb and returns NULL without advancing q->tail. The descriptors already consumed are then processed again on the next NAPI poll, even though their buffers have already been handed to the skb and recycled, leading to a use-after-free/double-free and possible memory corruption.
Rework RX processing to keep the partially built skb and the number of outstanding fragments across polls: store the skb in q->rx_head and the remaining fragment count in the new q->pending field. The new mt76_npu_rx_process_entry() consumes a whole packet, resuming a previously started one if needed, and advances q->tail for every consumed descriptor. Only fully received packets are passed up the stack.
Release any pending skb in mt76_npu_queue_cleanup() and add the missing DMA read barrier before accessing the descriptor length and info.
--- drivers/net/wireless/mediatek/mt76/mt76.h | 1 + drivers/net/wireless/mediatek/mt76/npu.c | 88 ++++++++++++++++++------------- 2 files changed, 51 insertions(+), 38 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76.h +1 -0
@@ -249,6 +249,7 @@ struct mt76_queue {int ndesc;int queued;int buf_size; +int pending;bool stopped;bool blocked;
drivers/net/wireless/mediatek/mt76/npu.c +50 -38
129 lines not on this page · raw message
---
base-commit: 763b13f622e2758726e8e3ecaef819db8fa0430a
change-id: 20261117-mt76-npu-fixes-ed72cc316a6a
Best regards,
Signature · 1 line
Lorenzo Bianconi <[email protected]>
Quoted 1 line · Lorenzo Bianconi
Tested-by Florian Maurer <[email protected]>
Thanks for posting. I ran the posted patch on mt76 467ae2e3 (W1700K, kernel 6.18.55) for another hour of iperf3. There are no oops, no page_pool warning, no refill or skb failure.
The missing rx slots from my mail of Nov 16 are still there (232 frames without LAST on their last slot, 7 unreadable tx-free events), but that is not caused by this patch. I will send the [BUG] report separately.
Thanks,
Florian