diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-10-17 14:32:07 -0400 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2017-10-18 03:39:14 -0400 |
commit | 2bdd713b92a9cade239d3c7d15205a09f556624d (patch) | |
tree | b441303ef59832d45fa555ee2bf3e52f7c13980c | |
parent | 1b72bf5a0777d7cec6c2d857ac15599022b3c123 (diff) |
mac80211: use constant time comparison with keys
Otherwise we risk leaking information via timing side channel.
Fixes: fdf7cb4185b6 ("mac80211: accept key reinstall without changing anything")
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
-rw-r--r-- | net/mac80211/key.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/net/mac80211/key.c b/net/mac80211/key.c index ae995c8480db..035d16fe926e 100644 --- a/net/mac80211/key.c +++ b/net/mac80211/key.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/slab.h> | 19 | #include <linux/slab.h> |
20 | #include <linux/export.h> | 20 | #include <linux/export.h> |
21 | #include <net/mac80211.h> | 21 | #include <net/mac80211.h> |
22 | #include <crypto/algapi.h> | ||
22 | #include <asm/unaligned.h> | 23 | #include <asm/unaligned.h> |
23 | #include "ieee80211_i.h" | 24 | #include "ieee80211_i.h" |
24 | #include "driver-ops.h" | 25 | #include "driver-ops.h" |
@@ -635,7 +636,7 @@ int ieee80211_key_link(struct ieee80211_key *key, | |||
635 | * new version of the key to avoid nonce reuse or replay issues. | 636 | * new version of the key to avoid nonce reuse or replay issues. |
636 | */ | 637 | */ |
637 | if (old_key && key->conf.keylen == old_key->conf.keylen && | 638 | if (old_key && key->conf.keylen == old_key->conf.keylen && |
638 | !memcmp(key->conf.key, old_key->conf.key, key->conf.keylen)) { | 639 | !crypto_memneq(key->conf.key, old_key->conf.key, key->conf.keylen)) { |
639 | ieee80211_key_free_unused(key); | 640 | ieee80211_key_free_unused(key); |
640 | ret = 0; | 641 | ret = 0; |
641 | goto out; | 642 | goto out; |