Skip to content

Commit 2586fa0

Browse files
jmberg-intelgregkh
authored andcommitted
mac80211: accept key reinstall without changing anything
commit fdf7cb4 upstream. When a key is reinstalled we can reset the replay counters etc. which can lead to nonce reuse and/or replay detection being impossible, breaking security properties, as described in the "KRACK attacks". In particular, CVE-2017-13080 applies to GTK rekeying that happened in firmware while the host is in D3, with the second part of the attack being done after the host wakes up. In this case, the wpa_supplicant mitigation isn't sufficient since wpa_supplicant doesn't know the GTK material. In case this happens, simply silently accept the new key coming from userspace but don't take any action on it since it's the same key; this keeps the PN replay counters intact. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Cc: Ben Hutchings <ben.hutchings@codethink.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent ac4cfc7 commit 2586fa0

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

net/mac80211/key.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
55
* Copyright 2007-2008 Johannes Berg <johannes@sipsolutions.net>
66
* Copyright 2013-2014 Intel Mobile Communications GmbH
7-
* Copyright 2015 Intel Deutschland GmbH
7+
* Copyright 2015-2017 Intel Deutschland GmbH
88
*
99
* This program is free software; you can redistribute it and/or modify
1010
* it under the terms of the GNU General Public License version 2 as
@@ -619,9 +619,6 @@ int ieee80211_key_link(struct ieee80211_key *key,
619619

620620
pairwise = key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE;
621621
idx = key->conf.keyidx;
622-
key->local = sdata->local;
623-
key->sdata = sdata;
624-
key->sta = sta;
625622

626623
mutex_lock(&sdata->local->key_mtx);
627624

@@ -632,6 +629,21 @@ int ieee80211_key_link(struct ieee80211_key *key,
632629
else
633630
old_key = key_mtx_dereference(sdata->local, sdata->keys[idx]);
634631

632+
/*
633+
* Silently accept key re-installation without really installing the
634+
* new version of the key to avoid nonce reuse or replay issues.
635+
*/
636+
if (old_key && key->conf.keylen == old_key->conf.keylen &&
637+
!memcmp(key->conf.key, old_key->conf.key, key->conf.keylen)) {
638+
ieee80211_key_free_unused(key);
639+
ret = 0;
640+
goto out;
641+
}
642+
643+
key->local = sdata->local;
644+
key->sdata = sdata;
645+
key->sta = sta;
646+
635647
increment_tailroom_need_count(sdata);
636648

637649
ieee80211_key_replace(sdata, sta, pairwise, old_key, key);
@@ -647,6 +659,7 @@ int ieee80211_key_link(struct ieee80211_key *key,
647659
ret = 0;
648660
}
649661

662+
out:
650663
mutex_unlock(&sdata->local->key_mtx);
651664

652665
return ret;

0 commit comments

Comments
 (0)