]> git.hungrycats.org Git - linux/commitdiff
mac80211: use constant time comparison with keys
authorJason A. Donenfeld <Jason@zx2c4.com>
Tue, 17 Oct 2017 18:32:07 +0000 (20:32 +0200)
committerSasha Levin <alexander.levin@verizon.com>
Thu, 7 Dec 2017 02:20:05 +0000 (21:20 -0500)
[ Upstream commit 2bdd713b92a9cade239d3c7d15205a09f556624d ]

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>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
net/mac80211/key.c

index e09be6f31f150cd4ea837086e474b150d778061f..6e280be8f7ee2501682cfacfd20e8e1d5e32a3aa 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/slab.h>
 #include <linux/export.h>
 #include <net/mac80211.h>
+#include <crypto/algapi.h>
 #include <asm/unaligned.h>
 #include "ieee80211_i.h"
 #include "driver-ops.h"
@@ -630,7 +631,7 @@ int ieee80211_key_link(struct ieee80211_key *key,
         * new version of the key to avoid nonce reuse or replay issues.
         */
        if (old_key && key->conf.keylen == old_key->conf.keylen &&
-           !memcmp(key->conf.key, old_key->conf.key, key->conf.keylen)) {
+           !crypto_memneq(key->conf.key, old_key->conf.key, key->conf.keylen)) {
                ieee80211_key_free_unused(key);
                ret = 0;
                goto out;