net: wwan: t7xx: fix potential skb->frags overflow in RX path v2
PATCH 1/1 net: wwan: t7xx: fix potential skb->frags overflow in RX path v2
When receiving data in the DPMAIF RX path,
the t7xx_dpmaif_set_frag_to_skb() function adds
page fragments to an skb without checking if the number of fragments has exceeded MAX_SKB_FRAGS. This could lead to a buffer overflow in skb_shinfo(skb)->frags[] array, corrupting adjacent memory and potentially causing kernel crashes or other undefined behavior.
This issue was identified through static code analysis by comparing with a similar vulnerability fixed in the mt76 driver commit b102f0c522cf ("mt76:
fix array overflow on receiving too many fragments for a packet").
The vulnerability could be triggered if the modem firmware sends packets with excessive fragments. While under normal protocol conditions (MTU 3080 bytes, BAT buffer 3584 bytes),
a single packet should not require additional
fragments, the kernel should not blindly trust firmware behavior. Malicious, buggy, or compromised firmware could potentially craft packets with more fragments than the kernel expects.
Fix this by adding a bounds check before calling skb_add_rx_frag() to ensure nr_frags does not exceed MAX_SKB_FRAGS.
The check must be performed before unmapping to avoid a page leak and double DMA unmap during device teardown.
--- drivers/net/wwan/t7xx/t7xx_hif_dpmaif_rx.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/net/wwan/t7xx/t7xx_hif_dpmaif_rx.c +7 -2
@@ -395,6 +395,7 @@ static int t7xx_dpmaif_set_frag_to_skb(const struct dpmaif_rx_queue *rxq, struct sk_buff *skb) {unsigned long long data_bus_addr, data_base_addr; +struct skb_shared_info *shinfo =skb_shinfo (skb);struct device *dev = rxq->dpmaif_ctrl->dev;struct dpmaif_bat_page *page_info;unsigned int data_len;
@@ -402,18 +403,22 @@ static int t7xx_dpmaif_set_frag_to_skb(const struct dpmaif_rx_queue *rxq, page_info = rxq->bat_frag->bat_skb; page_info +=t7xx_normal_pit_bid (pkt_info); -dma_unmap_page (dev, page_info->data_bus_addr, page_info->data_len,DMA_FROM_DEVICE );if (!page_info->page)return -EINVAL ; +if (shinfo->nr_frags >=MAX_SKB_FRAGS ) +return -EINVAL ; + +dma_unmap_page (dev, page_info->data_bus_addr, page_info->data_len,DMA_FROM_DEVICE ); + data_bus_addr =le32_to_cpu (pkt_info->pd.data_addr_h); data_bus_addr = (data_bus_addr <<32 ) +le32_to_cpu (pkt_info->pd.data_addr_l); data_base_addr = page_info->data_bus_addr; data_offset = data_bus_addr - data_base_addr; data_offset += page_info->offset; data_len =FIELD_GET (PD_PIT_DATA_LEN ,le32_to_cpu (pkt_info->header)); -skb_add_rx_frag (skb,skb_shinfo (skb)->nr_frags, page_info->page, +skb_add_rx_frag (skb, shinfo->nr_frags, page_info->page, data_offset, data_len, page_info->data_len); page_info->page =NULL ;
Signature · 1 line
2.34.1
Jakub Kicinski
maintainerQuoted 1 line · On Fri, 23 Jan 2026 01:04:01 +0800 Kery Qi wrote:
ubject: [PATCH] net: wwan: t7xx: fix potential
skb->fragsoverflow in RX path v2
Ugh, I think I got confused and send you the AI review for v1 again. The correct subject tag is [PATCH net v2]
Don't put the v2 in the patch title, please.
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Fri, 23 Jan 2026 01:04:01 +0800 you wrote:
When receiving data in the DPMAIF RX path,
thet7xx_dpmaif_set_frag_to_skb()function adds
page fragments to an skb without checking if the number of fragments has exceededMAX_SKB_FRAGS. This could lead to a buffer overflow in skb_shinfo(skb)->frags[] array, corrupting adjacent memory and potentially causing kernel crashes or other undefined behavior.[...]
Here is the summary with links:
- net: wwan: t7xx: fix potential skb->frags overflow in RX path v2
https://git.kernel.org/netdev/net/c/f0813bcd2d9d
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html