328-mac80211-use-constant-time-comparison-with-keys.patch 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. From 2bdd713b92a9cade239d3c7d15205a09f556624d Mon Sep 17 00:00:00 2001
  2. From: "Jason A. Donenfeld" <[email protected]>
  3. Date: Tue, 17 Oct 2017 20:32:07 +0200
  4. Subject: [PATCH] mac80211: use constant time comparison with keys
  5. Otherwise we risk leaking information via timing side channel.
  6. Fixes: fdf7cb4185b6 ("mac80211: accept key reinstall without changing anything")
  7. Signed-off-by: Jason A. Donenfeld <[email protected]>
  8. Signed-off-by: Johannes Berg <[email protected]>
  9. ---
  10. net/mac80211/key.c | 3 ++-
  11. 1 file changed, 2 insertions(+), 1 deletion(-)
  12. --- a/net/mac80211/key.c
  13. +++ b/net/mac80211/key.c
  14. @@ -19,6 +19,7 @@
  15. #include <linux/slab.h>
  16. #include <linux/export.h>
  17. #include <net/mac80211.h>
  18. +#include <crypto/algapi.h>
  19. #include <asm/unaligned.h>
  20. #include "ieee80211_i.h"
  21. #include "driver-ops.h"
  22. @@ -635,7 +636,7 @@ int ieee80211_key_link(struct ieee80211_
  23. * new version of the key to avoid nonce reuse or replay issues.
  24. */
  25. if (old_key && key->conf.keylen == old_key->conf.keylen &&
  26. - !memcmp(key->conf.key, old_key->conf.key, key->conf.keylen)) {
  27. + !crypto_memneq(key->conf.key, old_key->conf.key, key->conf.keylen)) {
  28. ieee80211_key_free_unused(key);
  29. ret = 0;
  30. goto out;