Skip to content

Commit 5e7a2c6

Browse files
committed
Merge tag 'wireless-drivers-2021-06-03' of git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers
Kalle Valo says: ==================== wireless-drivers fixes for v5.13 We have only mt76 fixes this time, most important being the fix for A-MSDU injection attacks. mt76 * mitigate A-MSDU injection attacks (CVE-2020-24588) * fix possible array out of bound access in mt7921_mcu_tx_rate_report * various aggregation and HE setting fixes * suspend/resume fix for pci devices * mt7615: fix crash when runtime-pm is not supported ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 5960786 + d4826d1 commit 5e7a2c6

File tree

11 files changed

+138
-30
lines changed

11 files changed

+138
-30
lines changed

drivers/net/wireless/mediatek/mt76/mac80211.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,10 +514,36 @@ EXPORT_SYMBOL_GPL(mt76_free_device);
514514
static void mt76_rx_release_amsdu(struct mt76_phy *phy, enum mt76_rxq_id q)
515515
{
516516
struct sk_buff *skb = phy->rx_amsdu[q].head;
517+
struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb;
517518
struct mt76_dev *dev = phy->dev;
518519

519520
phy->rx_amsdu[q].head = NULL;
520521
phy->rx_amsdu[q].tail = NULL;
522+
523+
/*
524+
* Validate if the amsdu has a proper first subframe.
525+
* A single MSDU can be parsed as A-MSDU when the unauthenticated A-MSDU
526+
* flag of the QoS header gets flipped. In such cases, the first
527+
* subframe has a LLC/SNAP header in the location of the destination
528+
* address.
529+
*/
530+
if (skb_shinfo(skb)->frag_list) {
531+
int offset = 0;
532+
533+
if (!(status->flag & RX_FLAG_8023)) {
534+
offset = ieee80211_get_hdrlen_from_skb(skb);
535+
536+
if ((status->flag &
537+
(RX_FLAG_DECRYPTED | RX_FLAG_IV_STRIPPED)) ==
538+
RX_FLAG_DECRYPTED)
539+
offset += 8;
540+
}
541+
542+
if (ether_addr_equal(skb->data + offset, rfc1042_header)) {
543+
dev_kfree_skb(skb);
544+
return;
545+
}
546+
}
521547
__skb_queue_tail(&dev->rx_skb[q], skb);
522548
}
523549

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,6 @@ void mt7615_init_device(struct mt7615_dev *dev)
510510
mutex_init(&dev->pm.mutex);
511511
init_waitqueue_head(&dev->pm.wait);
512512
spin_lock_init(&dev->pm.txq_lock);
513-
set_bit(MT76_STATE_PM, &dev->mphy.state);
514513
INIT_DELAYED_WORK(&dev->mphy.mac_work, mt7615_mac_work);
515514
INIT_DELAYED_WORK(&dev->phy.scan_work, mt7615_scan_work);
516515
INIT_DELAYED_WORK(&dev->coredump.work, mt7615_coredump_work);

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1912,8 +1912,9 @@ void mt7615_pm_wake_work(struct work_struct *work)
19121912
napi_schedule(&dev->mt76.napi[i]);
19131913
mt76_connac_pm_dequeue_skbs(mphy, &dev->pm);
19141914
mt76_queue_tx_cleanup(dev, dev->mt76.q_mcu[MT_MCUQ_WM], false);
1915-
ieee80211_queue_delayed_work(mphy->hw, &mphy->mac_work,
1916-
MT7615_WATCHDOG_TIME);
1915+
if (test_bit(MT76_STATE_RUNNING, &mphy->state))
1916+
ieee80211_queue_delayed_work(mphy->hw, &mphy->mac_work,
1917+
MT7615_WATCHDOG_TIME);
19171918
}
19181919

19191920
ieee80211_wake_queues(mphy->hw);

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,13 @@ mt7663s_mcu_send_message(struct mt76_dev *mdev, struct sk_buff *skb,
5151
return ret;
5252
}
5353

54-
static int mt7663s_mcu_drv_pmctrl(struct mt7615_dev *dev)
54+
static int __mt7663s_mcu_drv_pmctrl(struct mt7615_dev *dev)
5555
{
5656
struct sdio_func *func = dev->mt76.sdio.func;
5757
struct mt76_phy *mphy = &dev->mt76.phy;
5858
u32 status;
5959
int ret;
6060

61-
if (!test_and_clear_bit(MT76_STATE_PM, &mphy->state))
62-
goto out;
63-
6461
sdio_claim_host(func);
6562

6663
sdio_writel(func, WHLPCR_FW_OWN_REQ_CLR, MCR_WHLPCR, NULL);
@@ -76,13 +73,21 @@ static int mt7663s_mcu_drv_pmctrl(struct mt7615_dev *dev)
7673
}
7774

7875
sdio_release_host(func);
79-
80-
out:
8176
dev->pm.last_activity = jiffies;
8277

8378
return 0;
8479
}
8580

81+
static int mt7663s_mcu_drv_pmctrl(struct mt7615_dev *dev)
82+
{
83+
struct mt76_phy *mphy = &dev->mt76.phy;
84+
85+
if (test_and_clear_bit(MT76_STATE_PM, &mphy->state))
86+
return __mt7663s_mcu_drv_pmctrl(dev);
87+
88+
return 0;
89+
}
90+
8691
static int mt7663s_mcu_fw_pmctrl(struct mt7615_dev *dev)
8792
{
8893
struct sdio_func *func = dev->mt76.sdio.func;
@@ -123,7 +128,7 @@ int mt7663s_mcu_init(struct mt7615_dev *dev)
123128
struct mt7615_mcu_ops *mcu_ops;
124129
int ret;
125130

126-
ret = mt7663s_mcu_drv_pmctrl(dev);
131+
ret = __mt7663s_mcu_drv_pmctrl(dev);
127132
if (ret)
128133
return ret;
129134

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,7 @@ int mt7663u_mcu_init(struct mt7615_dev *dev)
5555

5656
dev->mt76.mcu_ops = &mt7663u_mcu_ops,
5757

58-
/* usb does not support runtime-pm */
59-
clear_bit(MT76_STATE_PM, &dev->mphy.state);
6058
mt76_set(dev, MT_UDMA_TX_QSEL, MT_FW_DL_EN);
61-
6259
if (test_and_clear_bit(MT76_STATE_POWER_OFF, &dev->mphy.state)) {
6360
mt7615_mcu_restart(&dev->mt76);
6461
if (!mt76_poll_msec(dev, MT_CONN_ON_MISC,

drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,10 @@ void mt76_connac_mcu_sta_tlv(struct mt76_phy *mphy, struct sk_buff *skb,
721721
phy->phy_type = mt76_connac_get_phy_mode_v2(mphy, vif, band, sta);
722722
phy->basic_rate = cpu_to_le16((u16)vif->bss_conf.basic_rates);
723723
phy->rcpi = rcpi;
724+
phy->ampdu = FIELD_PREP(IEEE80211_HT_AMPDU_PARM_FACTOR,
725+
sta->ht_cap.ampdu_factor) |
726+
FIELD_PREP(IEEE80211_HT_AMPDU_PARM_DENSITY,
727+
sta->ht_cap.ampdu_density);
724728

725729
tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_RA, sizeof(*ra_info));
726730
ra_info = (struct sta_rec_ra_info *)tlv;

drivers/net/wireless/mediatek/mt76/mt76x0/pci.c

Lines changed: 77 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ static const struct ieee80211_ops mt76x0e_ops = {
8787
.reconfig_complete = mt76x02_reconfig_complete,
8888
};
8989

90-
static int mt76x0e_register_device(struct mt76x02_dev *dev)
90+
static int mt76x0e_init_hardware(struct mt76x02_dev *dev, bool resume)
9191
{
9292
int err;
9393

@@ -100,9 +100,11 @@ static int mt76x0e_register_device(struct mt76x02_dev *dev)
100100
if (err < 0)
101101
return err;
102102

103-
err = mt76x02_dma_init(dev);
104-
if (err < 0)
105-
return err;
103+
if (!resume) {
104+
err = mt76x02_dma_init(dev);
105+
if (err < 0)
106+
return err;
107+
}
106108

107109
err = mt76x0_init_hardware(dev);
108110
if (err < 0)
@@ -123,6 +125,17 @@ static int mt76x0e_register_device(struct mt76x02_dev *dev)
123125
mt76_clear(dev, 0x110, BIT(9));
124126
mt76_set(dev, MT_MAX_LEN_CFG, BIT(13));
125127

128+
return 0;
129+
}
130+
131+
static int mt76x0e_register_device(struct mt76x02_dev *dev)
132+
{
133+
int err;
134+
135+
err = mt76x0e_init_hardware(dev, false);
136+
if (err < 0)
137+
return err;
138+
126139
err = mt76x0_register_device(dev);
127140
if (err < 0)
128141
return err;
@@ -167,6 +180,8 @@ mt76x0e_probe(struct pci_dev *pdev, const struct pci_device_id *id)
167180
if (ret)
168181
return ret;
169182

183+
mt76_pci_disable_aspm(pdev);
184+
170185
mdev = mt76_alloc_device(&pdev->dev, sizeof(*dev), &mt76x0e_ops,
171186
&drv_ops);
172187
if (!mdev)
@@ -220,6 +235,60 @@ mt76x0e_remove(struct pci_dev *pdev)
220235
mt76_free_device(mdev);
221236
}
222237

238+
#ifdef CONFIG_PM
239+
static int mt76x0e_suspend(struct pci_dev *pdev, pm_message_t state)
240+
{
241+
struct mt76_dev *mdev = pci_get_drvdata(pdev);
242+
struct mt76x02_dev *dev = container_of(mdev, struct mt76x02_dev, mt76);
243+
int i;
244+
245+
mt76_worker_disable(&mdev->tx_worker);
246+
for (i = 0; i < ARRAY_SIZE(mdev->phy.q_tx); i++)
247+
mt76_queue_tx_cleanup(dev, mdev->phy.q_tx[i], true);
248+
for (i = 0; i < ARRAY_SIZE(mdev->q_mcu); i++)
249+
mt76_queue_tx_cleanup(dev, mdev->q_mcu[i], true);
250+
napi_disable(&mdev->tx_napi);
251+
252+
mt76_for_each_q_rx(mdev, i)
253+
napi_disable(&mdev->napi[i]);
254+
255+
mt76x02_dma_disable(dev);
256+
mt76x02_mcu_cleanup(dev);
257+
mt76x0_chip_onoff(dev, false, false);
258+
259+
pci_enable_wake(pdev, pci_choose_state(pdev, state), true);
260+
pci_save_state(pdev);
261+
262+
return pci_set_power_state(pdev, pci_choose_state(pdev, state));
263+
}
264+
265+
static int mt76x0e_resume(struct pci_dev *pdev)
266+
{
267+
struct mt76_dev *mdev = pci_get_drvdata(pdev);
268+
struct mt76x02_dev *dev = container_of(mdev, struct mt76x02_dev, mt76);
269+
int err, i;
270+
271+
err = pci_set_power_state(pdev, PCI_D0);
272+
if (err)
273+
return err;
274+
275+
pci_restore_state(pdev);
276+
277+
mt76_worker_enable(&mdev->tx_worker);
278+
279+
mt76_for_each_q_rx(mdev, i) {
280+
mt76_queue_rx_reset(dev, i);
281+
napi_enable(&mdev->napi[i]);
282+
napi_schedule(&mdev->napi[i]);
283+
}
284+
285+
napi_enable(&mdev->tx_napi);
286+
napi_schedule(&mdev->tx_napi);
287+
288+
return mt76x0e_init_hardware(dev, true);
289+
}
290+
#endif /* CONFIG_PM */
291+
223292
static const struct pci_device_id mt76x0e_device_table[] = {
224293
{ PCI_DEVICE(PCI_VENDOR_ID_MEDIATEK, 0x7610) },
225294
{ PCI_DEVICE(PCI_VENDOR_ID_MEDIATEK, 0x7630) },
@@ -237,6 +306,10 @@ static struct pci_driver mt76x0e_driver = {
237306
.id_table = mt76x0e_device_table,
238307
.probe = mt76x0e_probe,
239308
.remove = mt76x0e_remove,
309+
#ifdef CONFIG_PM
310+
.suspend = mt76x0e_suspend,
311+
.resume = mt76x0e_resume,
312+
#endif /* CONFIG_PM */
240313
};
241314

242315
module_pci_driver(mt76x0e_driver);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ mt7921_init_wiphy(struct ieee80211_hw *hw)
7676
struct wiphy *wiphy = hw->wiphy;
7777

7878
hw->queues = 4;
79-
hw->max_rx_aggregation_subframes = IEEE80211_MAX_AMPDU_BUF;
80-
hw->max_tx_aggregation_subframes = IEEE80211_MAX_AMPDU_BUF;
79+
hw->max_rx_aggregation_subframes = 64;
80+
hw->max_tx_aggregation_subframes = 128;
8181

8282
hw->radiotap_timestamp.units_pos =
8383
IEEE80211_RADIOTAP_TIMESTAMP_UNIT_US;

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,8 +1404,9 @@ void mt7921_pm_wake_work(struct work_struct *work)
14041404
napi_schedule(&dev->mt76.napi[i]);
14051405
mt76_connac_pm_dequeue_skbs(mphy, &dev->pm);
14061406
mt7921_tx_cleanup(dev);
1407-
ieee80211_queue_delayed_work(mphy->hw, &mphy->mac_work,
1408-
MT7921_WATCHDOG_TIME);
1407+
if (test_bit(MT76_STATE_RUNNING, &mphy->state))
1408+
ieee80211_queue_delayed_work(mphy->hw, &mphy->mac_work,
1409+
MT7921_WATCHDOG_TIME);
14091410
}
14101411

14111412
ieee80211_wake_queues(mphy->hw);

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ mt7921_init_he_caps(struct mt7921_phy *phy, enum nl80211_band band,
7474
IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_IN_2G;
7575
else if (band == NL80211_BAND_5GHZ)
7676
he_cap_elem->phy_cap_info[0] =
77-
IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_80MHZ_IN_5G |
78-
IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_80PLUS80_MHZ_IN_5G;
77+
IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_80MHZ_IN_5G;
7978

8079
he_cap_elem->phy_cap_info[1] =
8180
IEEE80211_HE_PHY_CAP1_LDPC_CODING_IN_PAYLOAD;

0 commit comments

Comments
 (0)