Skip to contentSkip to conversation

mt76: fix buffer overrun in pkt buffer

PATCH In review [email protected] 2 participants 4 messages Oct 20 – Oct 30

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mt76: fix buffer overrun in pkt buffer

From: Anthony Liu <[email protected]>

The last patch (d4e5ca3483a0) addresses mt7928 F/W 4 byte-aligment requirement by reducing pkt buffer by 2 bytes, causing the chance of buffer overrun.

This patch reduces incoming skb length limit accordingly.

Fixes d4e5ca3483a0 ("wifi: mt76: mt7928: makes struct beacon_tlv 4-byte aligned.")
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +1 -1
index 26cdb3f0a98a..131585b3359d 100644
@@ -2479,7 +2479,7 @@ mt7925_mcu_uni_add_beacon_offload(struct mt792x_dev *dev,
 		return -EINVAL;
 	}
 
-	if (skb->len > 512) {
+	if (skb->len > 510) {
 		dev_err(dev->mt76.dev, "beacon size limit exceed\n");
 		dev_kfree_skb(skb);
 		return -EINVAL;
#1 lore raw
Quoted 19 lines · On Tue, Oct 20, 2026 at 11:22:00AM +0800, [email protected] wrote:

From: Anthony Liu <[email protected]>

The last patch (d4e5ca3483a0) addresses mt7928 F/W 4 byte-aligment requirement by reducing pkt buffer by 2 bytes, causing the chance of buffer overrun.

This patch reduces incoming skb length limit accordingly.

Fixes d4e5ca3483a0 ("wifi: mt76: mt7928: makes struct beacon_tlv 4-byte aligned.")
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +0 -0
index 26cdb3f0a98a..131585b3359d 100644

drivers/net/wireless/mediatek/mt76/mt7925/mcu.c mt7925_mcu_uni_add_beacon_offload(struct mt792x_dev *dev, · line 2482

Quoted 5 lines
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +1 -1
@@ -2479,7 +2479,7 @@ mt7925_mcu_uni_add_beacon_offload(struct mt792x_dev *dev,
 		return -EINVAL;
 	}
 
-	if (skb->len > 512) {
+	if (skb->len > 510) {

I would probably use:

	if (skb->len > sizeof(req.beacon_tlv.pkt)) {

but, we do need to apply this patch in linux-next.

regards,
dan carpenter

#2 lore raw

PATCH v2 1/1 mt76: fix buffer overrun in pkt buffer

The last patch (d4e5ca3483a0) addresses mt7928 F/W 4 byte-aligment requirement by reducing pkt buffer by 2 bytes, causing the chance of buffer overrun.

This patch reduces incoming skb length limit accordingly.

Fixes d4e5ca3483a0 ("wifi: mt76: mt7928: makes struct beacon_tlv 4-byte aligned.")
---
 drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +1 -1
index 50f5f57b740e..37aeccb28efb 100644
@@ -2537,7 +2537,7 @@ mt7925_mcu_uni_add_beacon_offload(struct mt792x_dev *dev,
 		return -EINVAL;
 	}
 
-	if (skb->len > 512) {
+	if (skb->len > sizeof(req.beacon_tlv.pkt)) {
 		dev_err(dev->mt76.dev, "beacon size limit exceed\n");
 		dev_kfree_skb(skb);
 		return -EINVAL;
Signature · 1 line
2.45.2
#3 lore raw
Quoted 6 lines · Anthony Liu

The last patch (d4e5ca3483a0) addresses mt7928 F/W 4 byte-aligment requirement by reducing pkt buffer by 2 bytes, causing the chance of buffer overrun.

This patch reduces incoming skb length limit accordingly.

Quoted 7 lines
Fixes d4e5ca3483a0 ("wifi: mt76: mt7928: makes struct beacon_tlv 4-byte aligned.")

---

Thanks!

regards,
dan carpenter