From a9eab62d41646cbf5d8b3408c9d4617bb9678e71 Mon Sep 17 00:00:00 2001 From: Lorenzo Bianconi Date: Fri, 9 Mar 2018 10:41:41 +0100 Subject: [PATCH] mt7601u: let mac80211 validate rx CCMP PN Git-commit: a9eab62d41646cbf5d8b3408c9d4617bb9678e71 Patch-mainline: v4.17-rc1 References: bsc#1051510 Apparently the hardware does not perform CCMP PN validation so let mac80211 take care of possible replay attacks in sw. Moreover indicate ICV and MIC had been stripped setting corresponding bits in ieee80211_rx_status. The fix has been validated using 4.2.1 and 4.1.3 tests from the WiFi Alliance vulnerability detection tool. Fixes: c869f77d6abb ("add mt7601u driver") Acked-by: Jakub Kicinski Tested-by: David Park Signed-off-by: Lorenzo Bianconi Signed-off-by: Kalle Valo Acked-by: Takashi Iwai --- drivers/net/wireless/mediatek/mt7601u/initvals.h | 1 + drivers/net/wireless/mediatek/mt7601u/mac.c | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) --- a/drivers/net/wireless/mediatek/mt7601u/initvals.h +++ b/drivers/net/wireless/mediatek/mt7601u/initvals.h @@ -139,6 +139,7 @@ static const struct mt76_reg_pair mac_co { MT_TXOP_HLDR_ET, 0x00000002 }, { MT_XIFS_TIME_CFG, 0x33a41010 }, { MT_PWR_PIN_CFG, 0x00000000 }, + { MT_PN_PAD_MODE, 0x00000001 }, }; static const struct mt76_reg_pair mac_chip_vals[] = { --- a/drivers/net/wireless/mediatek/mt7601u/mac.c +++ b/drivers/net/wireless/mediatek/mt7601u/mac.c @@ -464,8 +464,16 @@ u32 mt76_mac_process_rx(struct mt7601u_d if (rxwi->rxinfo & cpu_to_le32(MT_RXINFO_DECRYPT)) { status->flag |= RX_FLAG_DECRYPTED; - status->flag |= RX_FLAG_IV_STRIPPED | RX_FLAG_MMIC_STRIPPED; + status->flag |= RX_FLAG_MMIC_STRIPPED; + status->flag |= RX_FLAG_MIC_STRIPPED; + status->flag |= RX_FLAG_ICV_STRIPPED; + status->flag |= RX_FLAG_IV_STRIPPED; } + /* let mac80211 take care of PN validation since apparently + * the hardware does not support it + */ + if (rxwi->rxinfo & cpu_to_le32(MT_RXINFO_PN_LEN)) + status->flag &= ~RX_FLAG_IV_STRIPPED; status->chains = BIT(0); rssi = mt7601u_phy_get_rssi(dev, rxwi, rate);