Skip to content

Commit 7e44a0b

Browse files
committed
mac80211: prevent attacks on TKIP/WEP as well
Similar to the issues fixed in previous patches, TKIP and WEP should be protected even if for TKIP we have the Michael MIC protecting it, and WEP is broken anyway. However, this also somewhat protects potential other algorithms that drivers might implement. Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20210511200110.430e8c202313.Ia37e4e5b6b3eaab1a5ae050e015f6c92859dbe27@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent bf30ca9 commit 7e44a0b

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

‎net/mac80211/rx.c‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2274,6 +2274,7 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx)
22742274
* next fragment has a sequential PN value.
22752275
*/
22762276
entry->check_sequential_pn = true;
2277+
entry->is_protected = true;
22772278
entry->key_color = rx->key->color;
22782279
memcpy(entry->last_pn,
22792280
rx->key->u.ccmp.rx_pn[queue],
@@ -2286,6 +2287,9 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx)
22862287
sizeof(rx->key->u.gcmp.rx_pn[queue]));
22872288
BUILD_BUG_ON(IEEE80211_CCMP_PN_LEN !=
22882289
IEEE80211_GCMP_PN_LEN);
2290+
} else if (rx->key && ieee80211_has_protected(fc)) {
2291+
entry->is_protected = true;
2292+
entry->key_color = rx->key->color;
22892293
}
22902294
return RX_QUEUED;
22912295
}
@@ -2327,6 +2331,14 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx)
23272331
if (memcmp(pn, rpn, IEEE80211_CCMP_PN_LEN))
23282332
return RX_DROP_UNUSABLE;
23292333
memcpy(entry->last_pn, pn, IEEE80211_CCMP_PN_LEN);
2334+
} else if (entry->is_protected &&
2335+
(!rx->key || !ieee80211_has_protected(fc) ||
2336+
rx->key->color != entry->key_color)) {
2337+
/* Drop this as a mixed key or fragment cache attack, even
2338+
* if for TKIP Michael MIC should protect us, and WEP is a
2339+
* lost cause anyway.
2340+
*/
2341+
return RX_DROP_UNUSABLE;
23302342
}
23312343

23322344
skb_pull(rx->skb, ieee80211_hdrlen(fc));

‎net/mac80211/sta_info.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,8 @@ struct ieee80211_fragment_entry {
455455
u16 extra_len;
456456
u16 last_frag;
457457
u8 rx_queue;
458-
bool check_sequential_pn; /* needed for CCMP/GCMP */
458+
u8 check_sequential_pn:1, /* needed for CCMP/GCMP */
459+
is_protected:1;
459460
u8 last_pn[6]; /* PN of the last fragment if CCMP was used */
460461
unsigned int key_color;
461462
};

0 commit comments

Comments
 (0)