linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mac80211: Fix wlan freezes under load at rekey
@ 2018-03-24 10:29 Alexander Wetzel
  2018-03-24 15:29 ` Ben Greear
  2018-03-27 13:13 ` Johannes Berg
  0 siblings, 2 replies; 32+ messages in thread
From: Alexander Wetzel @ 2018-03-24 10:29 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, Alexander Wetzel

Rekeying a pairwise key with encryption offload and only keyid 0 has two
potential races which can freeze the wlan conection till rekeyed again:

 1) For incomming packets:
    If the local STA installs the key prior to the remote STA we still
    have the old key active in the hardware for a short time after
    mac80211 switched to the new key.
    The card can still hand over packets decoded with the old key to
    mac80211, bumping the new PN (IV) value to an incorrect high number and
    tricking the local replay detection to drop all packets really sent
    with the new key.

 2) For outgoing packets:
    If mac80211 is providing the PN (IV) and hands over the cleartext
    packets for encryption to the hardware immediately prior to a key
    change the driver/card may process the queued packets after
    switching to the new key.
    This will immediatelly bump the PN (IV) value on the remote STA to
    an incorrect high number, also freezing the connection.

Both issues can be prevented by deleting the key from the hardware prior
to switching to the new key in mac80211, falling back to software
encryption/decryption till the switch to the new key is completed.

Signed-off-by: Alexander Wetzel <alexander.wetzel@web.de>
---
 net/mac80211/key.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/net/mac80211/key.c b/net/mac80211/key.c
index aee05ec3f7ea..266ea0b507e7 100644
--- a/net/mac80211/key.c
+++ b/net/mac80211/key.c
@@ -332,10 +332,15 @@ static void ieee80211_key_replace(struct ieee80211_sub_if_data *sdata,
 
 	WARN_ON(new && old && new->conf.keyidx != old->conf.keyidx);
 
-	if (old)
+	if (old) {
 		idx = old->conf.keyidx;
-	else
+		/* Make sure the card can't encrypt/decrypt packets with
+		 * the old key prior to switching to new key in mac80211.
+		 */
+		ieee80211_key_disable_hw_accel(old);
+	} else {
 		idx = new->conf.keyidx;
+	}
 
 	if (sta) {
 		if (pairwise) {
-- 
2.16.2

^ permalink raw reply related	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2018-07-15 10:51 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-24 10:29 [PATCH] mac80211: Fix wlan freezes under load at rekey Alexander Wetzel
2018-03-24 15:29 ` Ben Greear
2018-03-25 19:45   ` Alexander Wetzel
2018-03-25 21:59     ` Ben Greear
2018-03-26  7:43       ` Sebastian Gottschall
2018-03-26 12:22       ` Sebastian Gottschall
2018-03-26 20:24         ` Alexander Wetzel
2018-03-27 13:03           ` Johannes Berg
2018-03-27 13:13 ` Johannes Berg
2018-04-08 20:31   ` Alexander Wetzel
2018-04-09  7:25     ` Johannes Berg
2018-05-15 10:22       ` [PATCH v2] " Alexander Wetzel
2018-05-15 15:50         ` Johannes Berg
2018-05-15 22:41           ` Alexander Wetzel
2018-05-16  6:56             ` Johannes Berg
2018-06-15 11:33         ` Johannes Berg
2018-06-18 21:03           ` Alexander Wetzel
2018-06-18 21:27             ` Johannes Berg
2018-06-19 20:12               ` Alexander Wetzel
2018-06-29 10:12                 ` Johannes Berg
2018-06-29 21:14                   ` Alexander Wetzel
2018-07-03  9:51                     ` Johannes Berg
2018-07-03 19:54                       ` Alexander Wetzel
2018-07-04  0:06                         ` Johannes Berg
2018-07-08  8:10                           ` Alexander Wetzel
2018-07-09  7:13                             ` Johannes Berg
2018-07-11 16:59                               ` Alexander Wetzel
2018-07-15  9:10                               ` [PATCH v2] mac80211: Fix wlan freezes/clear text packet leaks " Alexander Wetzel
2018-07-10 21:05                             ` [PATCH v2] mac80211: Fix wlan freezes under load " Denis Kenzior
2018-07-11 17:08                               ` Alexander Wetzel
2018-07-11 19:43                                 ` Denis Kenzior
2018-06-30 21:27                   ` [PATCH v3] mac80211: Fix PTK rekey freezes and cleartext leaks Alexander Wetzel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).