Skip to contentSkip to conversation

mt76: fix potential NULL pointer dereference in mt76_stop_tx_queues

PATCH In review Lorenzo Bianconi 4 participants 4 messages Nov 16, 2018 – Dec 13, 2018 3 messages not in the archive

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

PATCH 1/1 mt76: fix potential NULL pointer dereference in mt76_stop_tx_queues

In reply to a message not in the archive

Starting from mac80211 commit adf8ed01e4fd ("mac80211: add an optional TXQ for other PS-buffered frames") and commit 0eeb2b674f05 ("mac80211:
add an option for station management TXQ") a new per-sta queue has been introduced for bufferable management frames. sta->txq[IEEE80211_NUM_TIDS] is initialized just if the driver reports the following hw flags:
- IEEE80211_HW_STA_MMPDU_TXQ
- IEEE80211_HW_BUFF_MMPDU_TXQ
This can produce a NULL pointer dereference in mt76_stop_tx_queues since mt76 iterates on all available sta tx queues assuming they are initialized by mac80211. This issue has been spotted analyzing the code (it has not triggered any crash yet)

---
This patch is for 4.20

---
 drivers/net/wireless/mediatek/mt76/tx.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/tx.c +6 -1
index 7cbce03aa65b..aa426b838ffa 100644
@@ -400,7 +400,12 @@ void mt76_stop_tx_queues(struct mt76_dev *dev, struct ieee80211_sta *sta,
 
 	for (i = 0; i < ARRAY_SIZE(sta->txq); i++) {
 		struct ieee80211_txq *txq = sta->txq[i];
-		struct mt76_txq *mtxq = (struct mt76_txq *) txq->drv_priv;
+		struct mt76_txq *mtxq;
+
+		if (!txq)
+			continue;
+
+		mtxq = (struct mt76_txq *)txq->drv_priv;
 
 		spin_lock_bh(&mtxq->hwq->lock);
 		mtxq->send_bar = mtxq->aggr && send_bar;
Signature · 1 line
2.19.1
#3 lore raw
Quoted 13 lines · Lorenzo Bianconi

Starting from mac80211 commit adf8ed01e4fd ("mac80211: add an optional TXQ for other PS-buffered frames") and commit 0eeb2b674f05 ("mac80211:
add an option for station management TXQ") a new per-sta queue has been introduced for bufferable management frames. sta->txq[IEEE80211_NUM_TIDS] is initialized just if the driver reports the following hw flags:
- IEEE80211_HW_STA_MMPDU_TXQ
- IEEE80211_HW_BUFF_MMPDU_TXQ
This can produce a NULL pointer dereference in mt76_stop_tx_queues since mt76 iterates on all available sta tx queues assuming they are initialized by mac80211. This issue has been spotted analyzing the code (it has not triggered any crash yet)

Quoted 1 line

A very good commit log, thanks for that!

Quoted 1 line

This patch is for 4.20

Ok, I'll wait for review comments and then queue this for 4.20.

BTW, it would make my patch sorting easier if you could add a release label in the subject:

[PATCH 4.20] mt76: fix potential NULL pointer dereference in mt76_stop_tx_queues

More info:

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches#tree_labels

Signature · 1 line
Kalle Valo
#4 lore raw
Quoted 6 lines

A very good commit log, thanks for that!

Quoted 1 line

This patch is for 4.20

Ok, I'll wait for review comments and then queue this for 4.20.

Quoted 8 lines

BTW, it would make my patch sorting easier if you could add a release label in the subject:

[PATCH 4.20] mt76: fix potential NULL pointer dereference in mt76_stop_tx_queues

More info:

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches#tree_labels

Ack, will do next time :)

Regards,
Lorenzo

Quoted 3 lines

--
Kalle Valo

#6 lore raw
In reply to a message not in the archive
Quoted 13 lines · Lorenzo Bianconi

Starting from mac80211 commit adf8ed01e4fd ("mac80211: add an optional TXQ for other PS-buffered frames") and commit 0eeb2b674f05 ("mac80211:
add an option for station management TXQ") a new per-sta queue has been introduced for bufferable management frames. sta->txq[IEEE80211_NUM_TIDS] is initialized just if the driver reports the following hw flags:
- IEEE80211_HW_STA_MMPDU_TXQ
- IEEE80211_HW_BUFF_MMPDU_TXQ
This can produce a NULL pointer dereference in mt76_stop_tx_queues since mt76 iterates on all available sta tx queues assuming they are initialized by mac80211. This issue has been spotted analyzing the code (it has not triggered any crash yet)

Quoted 1 line

Patch applied to wireless-drivers.git, thanks.

7c250f4612ae mt76: fix potential NULL pointer dereference in mt76_stop_tx_queues

Signature · 3 lines
https://patchwork.kernel.org/patch/10686507/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches