rt2x00: use RESET state bit to prevent IV changes on restart
authorStanislaw Gruszka <sgruszka@redhat.com>
Thu, 28 Nov 2019 09:11:24 +0000 (10:11 +0100)
committerKalle Valo <kvalo@codeaurora.org>
Wed, 18 Dec 2019 18:55:56 +0000 (20:55 +0200)
We can not set IV when we are under reset. Previously we read previous
IV value from registers and zeroed IV registers when key was deleted,
but this could possibly not work if DEL_KEY command was not performed.

Now when we have ->reconfig_complete ops and we fully mark mac80211
reset state via DEVICE_STATE_RESET flag, we can just skip setting IV
when keys are set during reset.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/ralink/rt2x00/rt2800lib.c

index a36c3fe..6beac1f 100644 (file)
@@ -1652,20 +1652,17 @@ static void rt2800_config_wcid_attr_cipher(struct rt2x00_dev *rt2x00dev,
                rt2800_register_write(rt2x00dev, offset, reg);
        }
 
-       offset = MAC_IVEIV_ENTRY(key->hw_key_idx);
+       if (test_bit(DEVICE_STATE_RESET, &rt2x00dev->flags))
+               return;
 
-       if (crypto->cmd == SET_KEY) {
-               rt2800_register_multiread(rt2x00dev, offset,
-                                         &iveiv_entry, sizeof(iveiv_entry));
-               if ((crypto->cipher == CIPHER_TKIP) ||
-                   (crypto->cipher == CIPHER_TKIP_NO_MIC) ||
-                   (crypto->cipher == CIPHER_AES))
-                       iveiv_entry.iv[3] |= 0x20;
-               iveiv_entry.iv[3] |= key->keyidx << 6;
-       } else {
-               memset(&iveiv_entry, 0, sizeof(iveiv_entry));
-       }
+       offset = MAC_IVEIV_ENTRY(key->hw_key_idx);
 
+       memset(&iveiv_entry, 0, sizeof(iveiv_entry));
+       if ((crypto->cipher == CIPHER_TKIP) ||
+           (crypto->cipher == CIPHER_TKIP_NO_MIC) ||
+           (crypto->cipher == CIPHER_AES))
+               iveiv_entry.iv[3] |= 0x20;
+       iveiv_entry.iv[3] |= key->keyidx << 6;
        rt2800_register_multiwrite(rt2x00dev, offset,
                                   &iveiv_entry, sizeof(iveiv_entry));
 }