Skip to content

Commit 191587c

Browse files
LorenzoBianconiKalle Valo
authored andcommitted
mt76: fix key pointer overwrite in mt7921s_write_txwi/mt7663_usb_sdio_write_txwi
Fix pointer overwrite in mt7921s_tx_prepare_skb and mt7663_usb_sdio_tx_prepare_skb routines since in commit '2a9e9857473b ("mt76: fix possible pktid leak") mt76_tx_status_skb_add() has been moved out of mt7921s_write_txwi()/mt7663_usb_sdio_write_txwi() overwriting hw key pointer in ieee80211_tx_info structure. Fix the issue saving key pointer before running mt76_tx_status_skb_add(). Fixes: 2a9e985 ("mt76: fix possible pktid leak") Tested-by: Deren Wu <deren.wu@mediatek.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/eba40c84b6d114f618e2ae486cc6d0f2e9272cf9.1638193069.git.lorenzo@kernel.org
1 parent ed53ae7 commit 191587c

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

drivers/net/wireless/mediatek/mt76/mt7615/usb_sdio.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,11 @@ EXPORT_SYMBOL_GPL(mt7663_usb_sdio_reg_map);
4343
static void
4444
mt7663_usb_sdio_write_txwi(struct mt7615_dev *dev, struct mt76_wcid *wcid,
4545
enum mt76_txq_id qid, struct ieee80211_sta *sta,
46-
int pid, struct sk_buff *skb)
46+
struct ieee80211_key_conf *key, int pid,
47+
struct sk_buff *skb)
4748
{
48-
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
49-
struct ieee80211_key_conf *key = info->control.hw_key;
50-
__le32 *txwi;
49+
__le32 *txwi = (__le32 *)(skb->data - MT_USB_TXD_SIZE);
5150

52-
txwi = (__le32 *)(skb->data - MT_USB_TXD_SIZE);
5351
memset(txwi, 0, MT_USB_TXD_SIZE);
5452
mt7615_mac_write_txwi(dev, txwi, skb, wcid, sta, pid, key, false);
5553
skb_push(skb, MT_USB_TXD_SIZE);
@@ -188,6 +186,7 @@ int mt7663_usb_sdio_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
188186
struct mt7615_dev *dev = container_of(mdev, struct mt7615_dev, mt76);
189187
struct sk_buff *skb = tx_info->skb;
190188
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
189+
struct ieee80211_key_conf *key = info->control.hw_key;
191190
struct mt7615_sta *msta;
192191
int pad, err, pktid;
193192

@@ -205,7 +204,7 @@ int mt7663_usb_sdio_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
205204
}
206205

207206
pktid = mt76_tx_status_skb_add(&dev->mt76, wcid, skb);
208-
mt7663_usb_sdio_write_txwi(dev, wcid, qid, sta, pktid, skb);
207+
mt7663_usb_sdio_write_txwi(dev, wcid, qid, sta, key, pktid, skb);
209208
if (mt76_is_usb(mdev)) {
210209
u32 len = skb->len;
211210

drivers/net/wireless/mediatek/mt76/mt7921/sdio_mac.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,11 @@ int mt7921s_mac_reset(struct mt7921_dev *dev)
142142
static void
143143
mt7921s_write_txwi(struct mt7921_dev *dev, struct mt76_wcid *wcid,
144144
enum mt76_txq_id qid, struct ieee80211_sta *sta,
145-
int pid, struct sk_buff *skb)
145+
struct ieee80211_key_conf *key, int pid,
146+
struct sk_buff *skb)
146147
{
147-
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
148-
struct ieee80211_key_conf *key = info->control.hw_key;
149-
__le32 *txwi;
148+
__le32 *txwi = (__le32 *)(skb->data - MT_SDIO_TXD_SIZE);
150149

151-
txwi = (__le32 *)(skb->data - MT_SDIO_TXD_SIZE);
152150
memset(txwi, 0, MT_SDIO_TXD_SIZE);
153151
mt7921_mac_write_txwi(dev, txwi, skb, wcid, key, pid, false);
154152
skb_push(skb, MT_SDIO_TXD_SIZE);
@@ -161,6 +159,7 @@ int mt7921s_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
161159
{
162160
struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76);
163161
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx_info->skb);
162+
struct ieee80211_key_conf *key = info->control.hw_key;
164163
struct sk_buff *skb = tx_info->skb;
165164
int err, pad, pktid;
166165

@@ -180,7 +179,7 @@ int mt7921s_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
180179
}
181180

182181
pktid = mt76_tx_status_skb_add(&dev->mt76, wcid, skb);
183-
mt7921s_write_txwi(dev, wcid, qid, sta, pktid, skb);
182+
mt7921s_write_txwi(dev, wcid, qid, sta, key, pktid, skb);
184183

185184
mt7921_skb_add_sdio_hdr(skb, MT7921_SDIO_DATA);
186185
pad = round_up(skb->len, 4) - skb->len;

0 commit comments

Comments
 (0)