Skip to content

Commit bf710b6

Browse files
jmberg-intelgregkh
authored andcommitted
mac80211: prevent attacks on TKIP/WEP as well
commit 7e44a0b upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent e64ea05 commit bf710b6

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
@@ -2284,6 +2284,7 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx)
22842284
* next fragment has a sequential PN value.
22852285
*/
22862286
entry->check_sequential_pn = true;
2287+
entry->is_protected = true;
22872288
entry->key_color = rx->key->color;
22882289
memcpy(entry->last_pn,
22892290
rx->key->u.ccmp.rx_pn[queue],
@@ -2296,6 +2297,9 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx)
22962297
sizeof(rx->key->u.gcmp.rx_pn[queue]));
22972298
BUILD_BUG_ON(IEEE80211_CCMP_PN_LEN !=
22982299
IEEE80211_GCMP_PN_LEN);
2300+
} else if (rx->key && ieee80211_has_protected(fc)) {
2301+
entry->is_protected = true;
2302+
entry->key_color = rx->key->color;
22992303
}
23002304
return RX_QUEUED;
23012305
}
@@ -2337,6 +2341,14 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx)
23372341
if (memcmp(pn, rpn, IEEE80211_CCMP_PN_LEN))
23382342
return RX_DROP_UNUSABLE;
23392343
memcpy(entry->last_pn, pn, IEEE80211_CCMP_PN_LEN);
2344+
} else if (entry->is_protected &&
2345+
(!rx->key || !ieee80211_has_protected(fc) ||
2346+
rx->key->color != entry->key_color)) {
2347+
/* Drop this as a mixed key or fragment cache attack, even
2348+
* if for TKIP Michael MIC should protect us, and WEP is a
2349+
* lost cause anyway.
2350+
*/
2351+
return RX_DROP_UNUSABLE;
23402352
}
23412353

23422354
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
@@ -453,7 +453,8 @@ struct ieee80211_fragment_entry {
453453
u16 extra_len;
454454
u16 last_frag;
455455
u8 rx_queue;
456-
bool check_sequential_pn; /* needed for CCMP/GCMP */
456+
u8 check_sequential_pn:1, /* needed for CCMP/GCMP */
457+
is_protected:1;
457458
u8 last_pn[6]; /* PN of the last fragment if CCMP was used */
458459
unsigned int key_color;
459460
};

0 commit comments

Comments
 (0)