Skip to content

Commit 92ea8df

Browse files
committed
wifi: mac80211: reject WEP or pairwise keys with key ID > 3
We don't really care too much right now since our data structures are set up to not have a problem with this, but clearly it's wrong to accept WEP and pairwise keys with key ID > 3. However, with MLD we need to split into per-link (GTK, IGTK, BIGTK) and per interface/MLD (including WEP) keys so make sure this is not a problem. Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent 8092a0e commit 92ea8df

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

net/mac80211/key.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -433,13 +433,25 @@ static int ieee80211_key_replace(struct ieee80211_sub_if_data *sdata,
433433
int idx;
434434
int ret = 0;
435435
bool defunikey, defmultikey, defmgmtkey, defbeaconkey;
436+
bool is_wep;
436437

437438
/* caller must provide at least one old/new */
438439
if (WARN_ON(!new && !old))
439440
return 0;
440441

441-
if (new)
442+
if (new) {
443+
idx = new->conf.keyidx;
442444
list_add_tail_rcu(&new->list, &sdata->key_list);
445+
is_wep = new->conf.cipher == WLAN_CIPHER_SUITE_WEP40 ||
446+
new->conf.cipher == WLAN_CIPHER_SUITE_WEP104;
447+
} else {
448+
idx = old->conf.keyidx;
449+
is_wep = old->conf.cipher == WLAN_CIPHER_SUITE_WEP40 ||
450+
old->conf.cipher == WLAN_CIPHER_SUITE_WEP104;
451+
}
452+
453+
if ((is_wep || pairwise) && idx >= NUM_DEFAULT_KEYS)
454+
return -EINVAL;
443455

444456
WARN_ON(new && old && new->conf.keyidx != old->conf.keyidx);
445457

@@ -451,17 +463,13 @@ static int ieee80211_key_replace(struct ieee80211_sub_if_data *sdata,
451463
}
452464

453465
if (old) {
454-
idx = old->conf.keyidx;
455-
456466
if (old->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) {
457467
ieee80211_key_disable_hw_accel(old);
458468

459469
if (new)
460470
ret = ieee80211_key_enable_hw_accel(new);
461471
}
462472
} else {
463-
/* new must be provided in case old is not */
464-
idx = new->conf.keyidx;
465473
if (!new->local->wowlan)
466474
ret = ieee80211_key_enable_hw_accel(new);
467475
}

0 commit comments

Comments
 (0)