Skip to content

Commit 6440f0e

Browse files
jmberg-intelgregkh
authored andcommitted
mac80211: accept key reinstall without changing anything
commit fdf7cb4185b60c68e1a75e61691c4afdc15dea0e 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 c4e3d53 commit 6440f0e

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

net/mac80211/key.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +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 2017 Intel Deutschland GmbH
78
*
89
* This program is free software; you can redistribute it and/or modify
910
* it under the terms of the GNU General Public License version 2 as
@@ -617,9 +618,6 @@ int ieee80211_key_link(struct ieee80211_key *key,
617618

618619
pairwise = key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE;
619620
idx = key->conf.keyidx;
620-
key->local = sdata->local;
621-
key->sdata = sdata;
622-
key->sta = sta;
623621

624622
mutex_lock(&sdata->local->key_mtx);
625623

@@ -630,6 +628,21 @@ int ieee80211_key_link(struct ieee80211_key *key,
630628
else
631629
old_key = key_mtx_dereference(sdata->local, sdata->keys[idx]);
632630

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

635648
ieee80211_key_replace(sdata, sta, pairwise, old_key, key);
@@ -645,6 +658,7 @@ int ieee80211_key_link(struct ieee80211_key *key,
645658
ret = 0;
646659
}
647660

661+
out:
648662
mutex_unlock(&sdata->local->key_mtx);
649663

650664
return ret;

0 commit comments

Comments
 (0)