Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [PATCH mt76-next 11/20] wifi: mt76: mt7615: drop RX frame with a header gap past its end
       [not found] <20261129193131.3367661-1-nbd@nbd.name>
@ 2026-11-29 19:31 ` Felix Fietkau
  2026-11-29 20:43   ` Lorenzo Bianconi
  2026-11-29 19:31 ` [PATCH mt76-next 12/20] wifi: mt76: connac: drop a first fragment without an Ethernet header Felix Fietkau
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 16+ messages in thread
From: Felix Fietkau @ 2026-11-29 19:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: stable

mt7615_mac_fill_rx() does not check hdr_gap against the linear data of
the skb. A frame of several DMA buffers is not linear, and the hardware
sets the length of the first buffer. If hdr_gap is too large, skb_pull()
hits the BUG() in __skb_pull(), or fails and leaves no headroom, so the
__skb_push() in mt76_insert_ccmp_hdr() writes before skb->head. For a
first fragment, mt7615_reverse_frag0_hdr_trans() reads an Ethernet
header after hdr_gap, and a frame too short for it makes the skb_push()
of the LLC header hit skb_under_panic().

Drop the frame if hdr_gap is not within the linear data, or if a first
fragment holds no full Ethernet header there.

Fixes: 04b8e65922f6 ("mt76: add mac80211 driver for MT7615 PCIe-based chipsets")
Fixes: dc5399a50b45 ("mt76: reverse the first fragmented frame to 802.11")
Cc: stable@vger.kernel.org
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
 drivers/net/wireless/mediatek/mt76/mt7615/mac.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
index ff9c16977858..52c65c50bb60 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
@@ -257,6 +257,9 @@ static int mt7615_reverse_frag0_hdr_trans(struct sk_buff *skb, u16 hdr_gap)
 	struct ieee80211_hdr hdr;
 	u16 frame_control;
 
+	if (skb_headlen(skb) < hdr_gap + sizeof(*eth_hdr))
+		return -EINVAL;
+
 	if (le32_get_bits(rxd[1], MT_RXD1_NORMAL_ADDR_TYPE) !=
 	    MT_RXD1_NORMAL_U2M)
 		return -EINVAL;
@@ -594,6 +597,9 @@ static int mt7615_mac_fill_rx(struct mt7615_dev *dev, struct sk_buff *skb)
 	}
 
 	hdr_gap = (u8 *)rxd - skb->data + 2 * remove_pad;
+	if (hdr_gap >= skb_headlen(skb))
+		return -EINVAL;
+
 	if (hdr_trans && ieee80211_has_morefrags(fc)) {
 		if (mt7615_reverse_frag0_hdr_trans(skb, hdr_gap))
 			return -EINVAL;
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH mt76-next 12/20] wifi: mt76: connac: drop a first fragment without an Ethernet header
       [not found] <20261129193131.3367661-1-nbd@nbd.name>
  2026-11-29 19:31 ` [PATCH mt76-next 11/20] wifi: mt76: mt7615: drop RX frame with a header gap past its end Felix Fietkau
@ 2026-11-29 19:31 ` Felix Fietkau
  2026-11-29 20:43   ` Lorenzo Bianconi
  2026-11-29 19:31 ` [PATCH mt76-next 13/20] wifi: mt76: mt7915: drop RX frame with a header gap past its end Felix Fietkau
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 16+ messages in thread
From: Felix Fietkau @ 2026-11-29 19:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: stable

mt76_connac2_reverse_frag0_hdr_trans() reads an Ethernet header after
hdr_offset, but does not check that the linear data of the skb holds
one. A frame of several DMA buffers is not linear, and the hardware sets
the length of the first buffer. For a shorter first buffer, skb_pull()
hits the BUG() in __skb_pull(), or fails and leaves no headroom, so the
skb_push() of the LLC header hits skb_under_panic().

Drop a first fragment whose linear data holds no full Ethernet header
after the header gap.

Fixes: dc5399a50b45 ("mt76: reverse the first fragmented frame to 802.11")
Cc: stable@vger.kernel.org
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
 drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c b/drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c
index 6c2caade62d6..653d5162358e 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c
@@ -976,6 +976,9 @@ int mt76_connac2_reverse_frag0_hdr_trans(struct ieee80211_vif *vif,
 	struct ieee80211_hdr hdr;
 	u16 frame_control;
 
+	if (skb_headlen(skb) < hdr_offset + sizeof(*eth_hdr))
+		return -EINVAL;
+
 	if (le32_get_bits(rxd[3], MT_RXD3_NORMAL_ADDR_TYPE) !=
 	    MT_RXD3_NORMAL_U2M)
 		return -EINVAL;
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH mt76-next 13/20] wifi: mt76: mt7915: drop RX frame with a header gap past its end
       [not found] <20261129193131.3367661-1-nbd@nbd.name>
  2026-11-29 19:31 ` [PATCH mt76-next 11/20] wifi: mt76: mt7615: drop RX frame with a header gap past its end Felix Fietkau
  2026-11-29 19:31 ` [PATCH mt76-next 12/20] wifi: mt76: connac: drop a first fragment without an Ethernet header Felix Fietkau
@ 2026-11-29 19:31 ` Felix Fietkau
  2026-11-29 20:47   ` Lorenzo Bianconi
  2026-11-29 19:31 ` [PATCH mt76-next 14/20] wifi: mt76: mt7921: " Felix Fietkau
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 16+ messages in thread
From: Felix Fietkau @ 2026-11-29 19:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: stable

mt7915_mac_fill_rx() does not check hdr_gap against the linear data of
the skb. A frame of several DMA buffers is not linear, and the hardware
sets the length of the first buffer. If hdr_gap is too large, skb_pull()
hits the BUG() in __skb_pull(), or fails and leaves no headroom, so the
__skb_push() in mt76_insert_ccmp_hdr() writes before skb->head.

Drop the frame if hdr_gap is not within the linear data.

Fixes: e57b7901469f ("mt76: add mac80211 driver for MT7915 PCIe-based chipsets")
Cc: stable@vger.kernel.org
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
 drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
index dc23b8fcd216..334af60f543e 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
@@ -471,6 +471,9 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb,
 	}
 
 	hdr_gap = (u8 *)rxd - skb->data + 2 * remove_pad;
+	if (hdr_gap >= skb_headlen(skb))
+		return -EINVAL;
+
 	if (hdr_trans && ieee80211_has_morefrags(fc)) {
 		struct ieee80211_vif *vif;
 		int err;
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH mt76-next 14/20] wifi: mt76: mt7921: drop RX frame with a header gap past its end
       [not found] <20261129193131.3367661-1-nbd@nbd.name>
                   ` (2 preceding siblings ...)
  2026-11-29 19:31 ` [PATCH mt76-next 13/20] wifi: mt76: mt7915: drop RX frame with a header gap past its end Felix Fietkau
@ 2026-11-29 19:31 ` Felix Fietkau
  2026-11-29 20:47   ` Lorenzo Bianconi
  2026-11-29 19:31 ` [PATCH mt76-next 15/20] wifi: mt76: mt7996: " Felix Fietkau
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 16+ messages in thread
From: Felix Fietkau @ 2026-11-29 19:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: stable

mt7921_mac_fill_rx() does not check hdr_gap against the linear data of
the skb. A frame of several DMA buffers is not linear, and the hardware
sets the length of the first buffer. If hdr_gap is too large, skb_pull()
hits the BUG() in __skb_pull(), or fails and leaves no headroom, so the
__skb_push() in mt76_insert_ccmp_hdr() writes before skb->head.

Drop the frame if hdr_gap is not within the linear data.

Fixes: 163f4d22c118 ("mt76: mt7921: add MAC support")
Cc: stable@vger.kernel.org
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
 drivers/net/wireless/mediatek/mt76/mt7921/mac.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c
index 7f80ffbd278c..23bc0d946c56 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c
@@ -383,6 +383,9 @@ mt7921_mac_fill_rx(struct mt792x_dev *dev, struct sk_buff *skb)
 	}
 
 	hdr_gap = (u8 *)rxd - skb->data + 2 * remove_pad;
+	if (hdr_gap >= skb_headlen(skb))
+		return -EINVAL;
+
 	if (hdr_trans && ieee80211_has_morefrags(fc)) {
 		struct ieee80211_vif *vif;
 		int err;
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH mt76-next 15/20] wifi: mt76: mt7996: drop RX frame with a header gap past its end
       [not found] <20261129193131.3367661-1-nbd@nbd.name>
                   ` (3 preceding siblings ...)
  2026-11-29 19:31 ` [PATCH mt76-next 14/20] wifi: mt76: mt7921: " Felix Fietkau
@ 2026-11-29 19:31 ` Felix Fietkau
  2026-11-29 20:51   ` Lorenzo Bianconi
  2026-11-29 19:31 ` [PATCH mt76-next 16/20] wifi: mt76: mt7925: bound the header gap by the linear data of a frame Felix Fietkau
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 16+ messages in thread
From: Felix Fietkau @ 2026-11-29 19:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: stable

mt7996_mac_fill_rx() does not check hdr_gap against the linear data of
the skb. A frame of several DMA buffers is not linear, and the hardware
sets the length of the first buffer. If hdr_gap is too large, skb_pull()
hits the BUG() in __skb_pull(), or fails and leaves no headroom, so the
__skb_push() in mt76_insert_ccmp_hdr() writes before skb->head. For a
first fragment, mt7996_reverse_frag0_hdr_trans() reads an Ethernet
header after hdr_gap, and a frame too short for it makes the skb_push()
of the LLC header hit skb_under_panic().

Drop the frame if hdr_gap is not within the linear data, or if a first
fragment holds no full Ethernet header there.

Fixes: 98686cd21624 ("wifi: mt76: mt7996: add driver for MediaTek Wi-Fi 7 (802.11be) devices")
Cc: stable@vger.kernel.org
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
 drivers/net/wireless/mediatek/mt76/mt7996/mac.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mac.c b/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
index b2e871b679dd..dfce362a0cc9 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
@@ -203,6 +203,9 @@ static int mt7996_reverse_frag0_hdr_trans(struct sk_buff *skb, u16 hdr_gap)
 	struct mt7996_sta *msta;
 	u16 frame_control;
 
+	if (skb_headlen(skb) < hdr_gap + sizeof(*eth_hdr))
+		return -EINVAL;
+
 	if (le32_get_bits(rxd[3], MT_RXD3_NORMAL_ADDR_TYPE) !=
 	    MT_RXD3_NORMAL_U2M)
 		return -EINVAL;
@@ -642,6 +645,9 @@ mt7996_mac_fill_rx(struct mt7996_dev *dev, enum mt76_rxq_id q,
 		return -EINVAL;
 
 	hdr_gap = (u8 *)rxd - skb->data + 2 * remove_pad;
+	if (hdr_gap >= skb_headlen(skb))
+		return -EINVAL;
+
 	if (hdr_trans && ieee80211_has_morefrags(fc)) {
 		if (mt7996_reverse_frag0_hdr_trans(skb, hdr_gap))
 			return -EINVAL;
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH mt76-next 16/20] wifi: mt76: mt7925: bound the header gap by the linear data of a frame
       [not found] <20261129193131.3367661-1-nbd@nbd.name>
                   ` (4 preceding siblings ...)
  2026-11-29 19:31 ` [PATCH mt76-next 15/20] wifi: mt76: mt7996: " Felix Fietkau
@ 2026-11-29 19:31 ` Felix Fietkau
  2026-11-29 20:45   ` Lorenzo Bianconi
  2026-11-29 19:31 ` [PATCH mt76-next 17/20] wifi: mt76: mt7921: fix out-of-bounds read in mt7921_mac_add_txs Felix Fietkau
  2026-11-29 19:31 ` [PATCH mt76-next 18/20] wifi: mt76: mt7925: fix out-of-bounds read in mt7925_mac_add_txs Felix Fietkau
  7 siblings, 1 reply; 16+ messages in thread
From: Felix Fietkau @ 2026-11-29 19:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: stable

mt7925_mac_fill_rx() and mt7925_reverse_frag0_hdr_trans() check hdr_gap
against skb->len. A frame of several DMA buffers is not linear, and the
hardware sets the length of the first buffer. A hdr_gap past the linear
data thus still hits the BUG() in __skb_pull(), and the Ethernet header
of a first fragment is read past the linear data.

Check hdr_gap against the linear data of the skb.

Fixes: 211a71c64347 ("wifi: mt76: mt7925: drop RX frame with a header gap past its end")
Cc: stable@vger.kernel.org
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
 drivers/net/wireless/mediatek/mt76/mt7925/mac.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mac.c b/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
index d83a9fcb1bb0..09156e73df1a 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
@@ -215,7 +215,7 @@ static int mt7925_reverse_frag0_hdr_trans(struct sk_buff *skb, u16 hdr_gap)
 	struct ieee80211_hdr hdr;
 	u16 frame_control;
 
-	if (skb->len < hdr_gap + sizeof(*eth_hdr))
+	if (skb_headlen(skb) < hdr_gap + sizeof(*eth_hdr))
 		return -EINVAL;
 
 	if (le32_get_bits(rxd[3], MT_RXD3_NORMAL_ADDR_TYPE) !=
@@ -604,7 +604,7 @@ mt7925_mac_fill_rx(struct mt792x_dev *dev, struct sk_buff *skb)
 	}
 
 	hdr_gap = (u8 *)rxd - skb->data + 2 * remove_pad;
-	if (hdr_gap >= skb->len)
+	if (hdr_gap >= skb_headlen(skb))
 		return -EINVAL;
 
 	if (hdr_trans && ieee80211_has_morefrags(fc)) {
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH mt76-next 17/20] wifi: mt76: mt7921: fix out-of-bounds read in mt7921_mac_add_txs
       [not found] <20261129193131.3367661-1-nbd@nbd.name>
                   ` (5 preceding siblings ...)
  2026-11-29 19:31 ` [PATCH mt76-next 16/20] wifi: mt76: mt7925: bound the header gap by the linear data of a frame Felix Fietkau
@ 2026-11-29 19:31 ` Felix Fietkau
  2026-11-29 20:42   ` Lorenzo Bianconi
  2026-11-29 19:31 ` [PATCH mt76-next 18/20] wifi: mt76: mt7925: fix out-of-bounds read in mt7925_mac_add_txs Felix Fietkau
  7 siblings, 1 reply; 16+ messages in thread
From: Felix Fietkau @ 2026-11-29 19:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: stable

mt7921_queue_rx_skb() walks the TXS entries up to skb->len. An skb from
the USB scatter-gather RX path in mt76u_process_rx_entry() is not
linear, so skb->data only covers skb_headlen(skb) bytes, and the loop
reads past the head buffer of the skb.

Bound the walk by skb_headlen(skb). For a linear skb both lengths are
equal.

Fixes: 0d2afe09fad5 ("mt76: mt7921: add mt7921u driver")
Cc: stable@vger.kernel.org
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
 drivers/net/wireless/mediatek/mt76/mt7921/mac.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c
index 23bc0d946c56..1eb33d75c35d 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c
@@ -588,7 +588,7 @@ void mt7921_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q,
 {
 	struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76);
 	__le32 *rxd = (__le32 *)skb->data;
-	__le32 *end = (__le32 *)&skb->data[skb->len];
+	__le32 *end = (__le32 *)&skb->data[skb_headlen(skb)];
 	enum rx_pkt_type type;
 	u16 flag;
 
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH mt76-next 18/20] wifi: mt76: mt7925: fix out-of-bounds read in mt7925_mac_add_txs
       [not found] <20261129193131.3367661-1-nbd@nbd.name>
                   ` (6 preceding siblings ...)
  2026-11-29 19:31 ` [PATCH mt76-next 17/20] wifi: mt76: mt7921: fix out-of-bounds read in mt7921_mac_add_txs Felix Fietkau
@ 2026-11-29 19:31 ` Felix Fietkau
  2026-11-29 20:41   ` Lorenzo Bianconi
  7 siblings, 1 reply; 16+ messages in thread
From: Felix Fietkau @ 2026-11-29 19:31 UTC (permalink / raw)
  To: linux-wireless; +Cc: stable

mt7925_queue_rx_skb() walks the TXS entries up to skb->len. An skb from
the USB scatter-gather RX path in mt76u_process_rx_entry() is not
linear, so skb->data only covers skb_headlen(skb) bytes, and the loop
reads past the head buffer of the skb.

Bound the walk by skb_headlen(skb). For a linear skb both lengths are
equal.

Fixes: c948b5da6bbe ("wifi: mt76: mt7925: add Mediatek Wi-Fi7 driver for mt7925 chips")
Cc: stable@vger.kernel.org
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
 drivers/net/wireless/mediatek/mt76/mt7925/mac.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mac.c b/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
index 09156e73df1a..6d5abedcd507 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
@@ -1501,7 +1501,7 @@ void mt7925_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q,
 {
 	struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76);
 	__le32 *rxd = (__le32 *)skb->data;
-	__le32 *end = (__le32 *)&skb->data[skb->len];
+	__le32 *end = (__le32 *)&skb->data[skb_headlen(skb)];
 	enum rx_pkt_type type;
 	u16 flag;
 
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH mt76-next 18/20] wifi: mt76: mt7925: fix out-of-bounds read in mt7925_mac_add_txs
  2026-11-29 19:31 ` [PATCH mt76-next 18/20] wifi: mt76: mt7925: fix out-of-bounds read in mt7925_mac_add_txs Felix Fietkau
@ 2026-11-29 20:41   ` Lorenzo Bianconi
  0 siblings, 0 replies; 16+ messages in thread
From: Lorenzo Bianconi @ 2026-11-29 20:41 UTC (permalink / raw)
  To: Felix Fietkau; +Cc: linux-wireless, stable

[-- Attachment #1: Type: text/plain, Size: 1362 bytes --]

> mt7925_queue_rx_skb() walks the TXS entries up to skb->len. An skb from
> the USB scatter-gather RX path in mt76u_process_rx_entry() is not
> linear, so skb->data only covers skb_headlen(skb) bytes, and the loop
> reads past the head buffer of the skb.
> 
> Bound the walk by skb_headlen(skb). For a linear skb both lengths are
> equal.
> 
> Fixes: c948b5da6bbe ("wifi: mt76: mt7925: add Mediatek Wi-Fi7 driver for mt7925 chips")
> Cc: stable@vger.kernel.org
> Signed-off-by: Felix Fietkau <nbd@nbd.name>

Reviewed-by: Lorenzo Bianconi <lorenzo@kernel.org>

> ---
>  drivers/net/wireless/mediatek/mt76/mt7925/mac.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mac.c b/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
> index 09156e73df1a..6d5abedcd507 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
> @@ -1501,7 +1501,7 @@ void mt7925_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q,
>  {
>  	struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76);
>  	__le32 *rxd = (__le32 *)skb->data;
> -	__le32 *end = (__le32 *)&skb->data[skb->len];
> +	__le32 *end = (__le32 *)&skb->data[skb_headlen(skb)];
>  	enum rx_pkt_type type;
>  	u16 flag;
>  
> -- 
> 2.47.3
> 
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH mt76-next 17/20] wifi: mt76: mt7921: fix out-of-bounds read in mt7921_mac_add_txs
  2026-11-29 19:31 ` [PATCH mt76-next 17/20] wifi: mt76: mt7921: fix out-of-bounds read in mt7921_mac_add_txs Felix Fietkau
@ 2026-11-29 20:42   ` Lorenzo Bianconi
  0 siblings, 0 replies; 16+ messages in thread
From: Lorenzo Bianconi @ 2026-11-29 20:42 UTC (permalink / raw)
  To: Felix Fietkau; +Cc: linux-wireless, stable

[-- Attachment #1: Type: text/plain, Size: 1362 bytes --]

On Nov 29, Felix Fietkau wrote:
> mt7921_queue_rx_skb() walks the TXS entries up to skb->len. An skb from
> the USB scatter-gather RX path in mt76u_process_rx_entry() is not
> linear, so skb->data only covers skb_headlen(skb) bytes, and the loop
> reads past the head buffer of the skb.
> 
> Bound the walk by skb_headlen(skb). For a linear skb both lengths are
> equal.
> 
> Fixes: 0d2afe09fad5 ("mt76: mt7921: add mt7921u driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Felix Fietkau <nbd@nbd.name>

Reviewed-by: Lorenzo Bianconi <lorenzo@kernel.org>

> ---
>  drivers/net/wireless/mediatek/mt76/mt7921/mac.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c
> index 23bc0d946c56..1eb33d75c35d 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c
> @@ -588,7 +588,7 @@ void mt7921_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q,
>  {
>  	struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76);
>  	__le32 *rxd = (__le32 *)skb->data;
> -	__le32 *end = (__le32 *)&skb->data[skb->len];
> +	__le32 *end = (__le32 *)&skb->data[skb_headlen(skb)];
>  	enum rx_pkt_type type;
>  	u16 flag;
>  
> -- 
> 2.47.3
> 
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH mt76-next 12/20] wifi: mt76: connac: drop a first fragment without an Ethernet header
  2026-11-29 19:31 ` [PATCH mt76-next 12/20] wifi: mt76: connac: drop a first fragment without an Ethernet header Felix Fietkau
@ 2026-11-29 20:43   ` Lorenzo Bianconi
  0 siblings, 0 replies; 16+ messages in thread
From: Lorenzo Bianconi @ 2026-11-29 20:43 UTC (permalink / raw)
  To: Felix Fietkau; +Cc: linux-wireless, stable

[-- Attachment #1: Type: text/plain, Size: 1519 bytes --]

> mt76_connac2_reverse_frag0_hdr_trans() reads an Ethernet header after
> hdr_offset, but does not check that the linear data of the skb holds
> one. A frame of several DMA buffers is not linear, and the hardware sets
> the length of the first buffer. For a shorter first buffer, skb_pull()
> hits the BUG() in __skb_pull(), or fails and leaves no headroom, so the
> skb_push() of the LLC header hits skb_under_panic().
> 
> Drop a first fragment whose linear data holds no full Ethernet header
> after the header gap.
> 
> Fixes: dc5399a50b45 ("mt76: reverse the first fragmented frame to 802.11")
> Cc: stable@vger.kernel.org
> Signed-off-by: Felix Fietkau <nbd@nbd.name>

Reviewed-by: Lorenzo Bianconi <lorenzo@kernel.org>

> ---
>  drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c b/drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c
> index 6c2caade62d6..653d5162358e 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c
> @@ -976,6 +976,9 @@ int mt76_connac2_reverse_frag0_hdr_trans(struct ieee80211_vif *vif,
>  	struct ieee80211_hdr hdr;
>  	u16 frame_control;
>  
> +	if (skb_headlen(skb) < hdr_offset + sizeof(*eth_hdr))
> +		return -EINVAL;
> +
>  	if (le32_get_bits(rxd[3], MT_RXD3_NORMAL_ADDR_TYPE) !=
>  	    MT_RXD3_NORMAL_U2M)
>  		return -EINVAL;
> -- 
> 2.47.3
> 
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH mt76-next 11/20] wifi: mt76: mt7615: drop RX frame with a header gap past its end
  2026-11-29 19:31 ` [PATCH mt76-next 11/20] wifi: mt76: mt7615: drop RX frame with a header gap past its end Felix Fietkau
@ 2026-11-29 20:43   ` Lorenzo Bianconi
  0 siblings, 0 replies; 16+ messages in thread
From: Lorenzo Bianconi @ 2026-11-29 20:43 UTC (permalink / raw)
  To: Felix Fietkau; +Cc: linux-wireless, stable

[-- Attachment #1: Type: text/plain, Size: 2142 bytes --]

On Nov 29, Felix Fietkau wrote:
> mt7615_mac_fill_rx() does not check hdr_gap against the linear data of
> the skb. A frame of several DMA buffers is not linear, and the hardware
> sets the length of the first buffer. If hdr_gap is too large, skb_pull()
> hits the BUG() in __skb_pull(), or fails and leaves no headroom, so the
> __skb_push() in mt76_insert_ccmp_hdr() writes before skb->head. For a
> first fragment, mt7615_reverse_frag0_hdr_trans() reads an Ethernet
> header after hdr_gap, and a frame too short for it makes the skb_push()
> of the LLC header hit skb_under_panic().
> 
> Drop the frame if hdr_gap is not within the linear data, or if a first
> fragment holds no full Ethernet header there.
> 
> Fixes: 04b8e65922f6 ("mt76: add mac80211 driver for MT7615 PCIe-based chipsets")
> Fixes: dc5399a50b45 ("mt76: reverse the first fragmented frame to 802.11")
> Cc: stable@vger.kernel.org
> Signed-off-by: Felix Fietkau <nbd@nbd.name>

Reviewed-by: Lorenzo Bianconi <lorenzo@kernel.org>

> ---
>  drivers/net/wireless/mediatek/mt76/mt7615/mac.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
> index ff9c16977858..52c65c50bb60 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
> @@ -257,6 +257,9 @@ static int mt7615_reverse_frag0_hdr_trans(struct sk_buff *skb, u16 hdr_gap)
>  	struct ieee80211_hdr hdr;
>  	u16 frame_control;
>  
> +	if (skb_headlen(skb) < hdr_gap + sizeof(*eth_hdr))
> +		return -EINVAL;
> +
>  	if (le32_get_bits(rxd[1], MT_RXD1_NORMAL_ADDR_TYPE) !=
>  	    MT_RXD1_NORMAL_U2M)
>  		return -EINVAL;
> @@ -594,6 +597,9 @@ static int mt7615_mac_fill_rx(struct mt7615_dev *dev, struct sk_buff *skb)
>  	}
>  
>  	hdr_gap = (u8 *)rxd - skb->data + 2 * remove_pad;
> +	if (hdr_gap >= skb_headlen(skb))
> +		return -EINVAL;
> +
>  	if (hdr_trans && ieee80211_has_morefrags(fc)) {
>  		if (mt7615_reverse_frag0_hdr_trans(skb, hdr_gap))
>  			return -EINVAL;
> -- 
> 2.47.3
> 
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH mt76-next 16/20] wifi: mt76: mt7925: bound the header gap by the linear data of a frame
  2026-11-29 19:31 ` [PATCH mt76-next 16/20] wifi: mt76: mt7925: bound the header gap by the linear data of a frame Felix Fietkau
@ 2026-11-29 20:45   ` Lorenzo Bianconi
  0 siblings, 0 replies; 16+ messages in thread
From: Lorenzo Bianconi @ 2026-11-29 20:45 UTC (permalink / raw)
  To: Felix Fietkau; +Cc: linux-wireless, stable

[-- Attachment #1: Type: text/plain, Size: 1744 bytes --]

On Nov 29, Felix Fietkau wrote:
> mt7925_mac_fill_rx() and mt7925_reverse_frag0_hdr_trans() check hdr_gap
> against skb->len. A frame of several DMA buffers is not linear, and the
> hardware sets the length of the first buffer. A hdr_gap past the linear
> data thus still hits the BUG() in __skb_pull(), and the Ethernet header
> of a first fragment is read past the linear data.
> 
> Check hdr_gap against the linear data of the skb.
> 
> Fixes: 211a71c64347 ("wifi: mt76: mt7925: drop RX frame with a header gap past its end")
> Cc: stable@vger.kernel.org
> Signed-off-by: Felix Fietkau <nbd@nbd.name>

Reviewed-by: Lorenzo Bianconi <lorenzo@kernel.org>

> ---
>  drivers/net/wireless/mediatek/mt76/mt7925/mac.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mac.c b/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
> index d83a9fcb1bb0..09156e73df1a 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
> @@ -215,7 +215,7 @@ static int mt7925_reverse_frag0_hdr_trans(struct sk_buff *skb, u16 hdr_gap)
>  	struct ieee80211_hdr hdr;
>  	u16 frame_control;
>  
> -	if (skb->len < hdr_gap + sizeof(*eth_hdr))
> +	if (skb_headlen(skb) < hdr_gap + sizeof(*eth_hdr))
>  		return -EINVAL;
>  
>  	if (le32_get_bits(rxd[3], MT_RXD3_NORMAL_ADDR_TYPE) !=
> @@ -604,7 +604,7 @@ mt7925_mac_fill_rx(struct mt792x_dev *dev, struct sk_buff *skb)
>  	}
>  
>  	hdr_gap = (u8 *)rxd - skb->data + 2 * remove_pad;
> -	if (hdr_gap >= skb->len)
> +	if (hdr_gap >= skb_headlen(skb))
>  		return -EINVAL;
>  
>  	if (hdr_trans && ieee80211_has_morefrags(fc)) {
> -- 
> 2.47.3
> 
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH mt76-next 13/20] wifi: mt76: mt7915: drop RX frame with a header gap past its end
  2026-11-29 19:31 ` [PATCH mt76-next 13/20] wifi: mt76: mt7915: drop RX frame with a header gap past its end Felix Fietkau
@ 2026-11-29 20:47   ` Lorenzo Bianconi
  0 siblings, 0 replies; 16+ messages in thread
From: Lorenzo Bianconi @ 2026-11-29 20:47 UTC (permalink / raw)
  To: Felix Fietkau; +Cc: linux-wireless, stable

[-- Attachment #1: Type: text/plain, Size: 1375 bytes --]

> mt7915_mac_fill_rx() does not check hdr_gap against the linear data of
> the skb. A frame of several DMA buffers is not linear, and the hardware
> sets the length of the first buffer. If hdr_gap is too large, skb_pull()
> hits the BUG() in __skb_pull(), or fails and leaves no headroom, so the
> __skb_push() in mt76_insert_ccmp_hdr() writes before skb->head.
> 
> Drop the frame if hdr_gap is not within the linear data.
> 
> Fixes: e57b7901469f ("mt76: add mac80211 driver for MT7915 PCIe-based chipsets")
> Cc: stable@vger.kernel.org
> Signed-off-by: Felix Fietkau <nbd@nbd.name>

Reviewed-by: Lorenzo Bianconi <lorenzo@kernel.org>

> ---
>  drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
> index dc23b8fcd216..334af60f543e 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
> @@ -471,6 +471,9 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb,
>  	}
>  
>  	hdr_gap = (u8 *)rxd - skb->data + 2 * remove_pad;
> +	if (hdr_gap >= skb_headlen(skb))
> +		return -EINVAL;
> +
>  	if (hdr_trans && ieee80211_has_morefrags(fc)) {
>  		struct ieee80211_vif *vif;
>  		int err;
> -- 
> 2.47.3
> 
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH mt76-next 14/20] wifi: mt76: mt7921: drop RX frame with a header gap past its end
  2026-11-29 19:31 ` [PATCH mt76-next 14/20] wifi: mt76: mt7921: " Felix Fietkau
@ 2026-11-29 20:47   ` Lorenzo Bianconi
  0 siblings, 0 replies; 16+ messages in thread
From: Lorenzo Bianconi @ 2026-11-29 20:47 UTC (permalink / raw)
  To: Felix Fietkau; +Cc: linux-wireless, stable

[-- Attachment #1: Type: text/plain, Size: 1381 bytes --]

On Nov 29, Felix Fietkau wrote:
> mt7921_mac_fill_rx() does not check hdr_gap against the linear data of
> the skb. A frame of several DMA buffers is not linear, and the hardware
> sets the length of the first buffer. If hdr_gap is too large, skb_pull()
> hits the BUG() in __skb_pull(), or fails and leaves no headroom, so the
> __skb_push() in mt76_insert_ccmp_hdr() writes before skb->head.
> 
> Drop the frame if hdr_gap is not within the linear data.
> 
> Fixes: 163f4d22c118 ("mt76: mt7921: add MAC support")
> Cc: stable@vger.kernel.org
> Signed-off-by: Felix Fietkau <nbd@nbd.name>

Reviewed-by: Lorenzo Bianconi <lorenzo@kernel.org>

> ---
>  drivers/net/wireless/mediatek/mt76/mt7921/mac.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c
> index 7f80ffbd278c..23bc0d946c56 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c
> @@ -383,6 +383,9 @@ mt7921_mac_fill_rx(struct mt792x_dev *dev, struct sk_buff *skb)
>  	}
>  
>  	hdr_gap = (u8 *)rxd - skb->data + 2 * remove_pad;
> +	if (hdr_gap >= skb_headlen(skb))
> +		return -EINVAL;
> +
>  	if (hdr_trans && ieee80211_has_morefrags(fc)) {
>  		struct ieee80211_vif *vif;
>  		int err;
> -- 
> 2.47.3
> 
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH mt76-next 15/20] wifi: mt76: mt7996: drop RX frame with a header gap past its end
  2026-11-29 19:31 ` [PATCH mt76-next 15/20] wifi: mt76: mt7996: " Felix Fietkau
@ 2026-11-29 20:51   ` Lorenzo Bianconi
  0 siblings, 0 replies; 16+ messages in thread
From: Lorenzo Bianconi @ 2026-11-29 20:51 UTC (permalink / raw)
  To: Felix Fietkau; +Cc: linux-wireless, stable

[-- Attachment #1: Type: text/plain, Size: 2047 bytes --]

> mt7996_mac_fill_rx() does not check hdr_gap against the linear data of
> the skb. A frame of several DMA buffers is not linear, and the hardware
> sets the length of the first buffer. If hdr_gap is too large, skb_pull()
> hits the BUG() in __skb_pull(), or fails and leaves no headroom, so the
> __skb_push() in mt76_insert_ccmp_hdr() writes before skb->head. For a
> first fragment, mt7996_reverse_frag0_hdr_trans() reads an Ethernet
> header after hdr_gap, and a frame too short for it makes the skb_push()
> of the LLC header hit skb_under_panic().
> 
> Drop the frame if hdr_gap is not within the linear data, or if a first
> fragment holds no full Ethernet header there.
> 
> Fixes: 98686cd21624 ("wifi: mt76: mt7996: add driver for MediaTek Wi-Fi 7 (802.11be) devices")
> Cc: stable@vger.kernel.org
> Signed-off-by: Felix Fietkau <nbd@nbd.name>

Reviewed-by: Lorenzo Bianconi <lorenzo@kernel.org>

> ---
>  drivers/net/wireless/mediatek/mt76/mt7996/mac.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mac.c b/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
> index b2e871b679dd..dfce362a0cc9 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
> @@ -203,6 +203,9 @@ static int mt7996_reverse_frag0_hdr_trans(struct sk_buff *skb, u16 hdr_gap)
>  	struct mt7996_sta *msta;
>  	u16 frame_control;
>  
> +	if (skb_headlen(skb) < hdr_gap + sizeof(*eth_hdr))
> +		return -EINVAL;
> +
>  	if (le32_get_bits(rxd[3], MT_RXD3_NORMAL_ADDR_TYPE) !=
>  	    MT_RXD3_NORMAL_U2M)
>  		return -EINVAL;
> @@ -642,6 +645,9 @@ mt7996_mac_fill_rx(struct mt7996_dev *dev, enum mt76_rxq_id q,
>  		return -EINVAL;
>  
>  	hdr_gap = (u8 *)rxd - skb->data + 2 * remove_pad;
> +	if (hdr_gap >= skb_headlen(skb))
> +		return -EINVAL;
> +
>  	if (hdr_trans && ieee80211_has_morefrags(fc)) {
>  		if (mt7996_reverse_frag0_hdr_trans(skb, hdr_gap))
>  			return -EINVAL;
> -- 
> 2.47.3
> 
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2026-11-29 20:51 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20261129193131.3367661-1-nbd@nbd.name>
2026-11-29 19:31 ` [PATCH mt76-next 11/20] wifi: mt76: mt7615: drop RX frame with a header gap past its end Felix Fietkau
2026-11-29 20:43   ` Lorenzo Bianconi
2026-11-29 19:31 ` [PATCH mt76-next 12/20] wifi: mt76: connac: drop a first fragment without an Ethernet header Felix Fietkau
2026-11-29 20:43   ` Lorenzo Bianconi
2026-11-29 19:31 ` [PATCH mt76-next 13/20] wifi: mt76: mt7915: drop RX frame with a header gap past its end Felix Fietkau
2026-11-29 20:47   ` Lorenzo Bianconi
2026-11-29 19:31 ` [PATCH mt76-next 14/20] wifi: mt76: mt7921: " Felix Fietkau
2026-11-29 20:47   ` Lorenzo Bianconi
2026-11-29 19:31 ` [PATCH mt76-next 15/20] wifi: mt76: mt7996: " Felix Fietkau
2026-11-29 20:51   ` Lorenzo Bianconi
2026-11-29 19:31 ` [PATCH mt76-next 16/20] wifi: mt76: mt7925: bound the header gap by the linear data of a frame Felix Fietkau
2026-11-29 20:45   ` Lorenzo Bianconi
2026-11-29 19:31 ` [PATCH mt76-next 17/20] wifi: mt76: mt7921: fix out-of-bounds read in mt7921_mac_add_txs Felix Fietkau
2026-11-29 20:42   ` Lorenzo Bianconi
2026-11-29 19:31 ` [PATCH mt76-next 18/20] wifi: mt76: mt7925: fix out-of-bounds read in mt7925_mac_add_txs Felix Fietkau
2026-11-29 20:41   ` Lorenzo Bianconi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox