Skip to content

Commit 144cd24

Browse files
Jouni MalinenKalle Valo
authored andcommitted
ath: Modify ath_key_delete() to not need full key entry
tkip_keymap can be used internally to avoid the reference to key->cipher and with this, only the key index value itself is needed. This allows ath_key_delete() call to be postponed to be handled after the upper layer STA and key entry have already been removed. This is needed to make ath9k key cache management safer. Signed-off-by: Jouni Malinen <[email protected]> Signed-off-by: Kalle Valo <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent d2d3e36 commit 144cd24

File tree

5 files changed

+22
-23
lines changed

5 files changed

+22
-23
lines changed

drivers/net/wireless/ath/ath.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ struct sk_buff *ath_rxbuf_alloc(struct ath_common *common,
197197
bool ath_is_mybeacon(struct ath_common *common, struct ieee80211_hdr *hdr);
198198

199199
void ath_hw_setbssidmask(struct ath_common *common);
200-
void ath_key_delete(struct ath_common *common, struct ieee80211_key_conf *key);
200+
void ath_key_delete(struct ath_common *common, u8 hw_key_idx);
201201
int ath_key_config(struct ath_common *common,
202202
struct ieee80211_vif *vif,
203203
struct ieee80211_sta *sta,

drivers/net/wireless/ath/ath5k/mac80211-ops.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ ath5k_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
522522
}
523523
break;
524524
case DISABLE_KEY:
525-
ath_key_delete(common, key);
525+
ath_key_delete(common, key->hw_key_idx);
526526
break;
527527
default:
528528
ret = -EINVAL;

drivers/net/wireless/ath/ath9k/htc_drv_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1461,7 +1461,7 @@ static int ath9k_htc_set_key(struct ieee80211_hw *hw,
14611461
}
14621462
break;
14631463
case DISABLE_KEY:
1464-
ath_key_delete(common, key);
1464+
ath_key_delete(common, key->hw_key_idx);
14651465
break;
14661466
default:
14671467
ret = -EINVAL;

drivers/net/wireless/ath/ath9k/main.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,12 +1543,11 @@ static void ath9k_del_ps_key(struct ath_softc *sc,
15431543
{
15441544
struct ath_common *common = ath9k_hw_common(sc->sc_ah);
15451545
struct ath_node *an = (struct ath_node *) sta->drv_priv;
1546-
struct ieee80211_key_conf ps_key = { .hw_key_idx = an->ps_key };
15471546

15481547
if (!an->ps_key)
15491548
return;
15501549

1551-
ath_key_delete(common, &ps_key);
1550+
ath_key_delete(common, an->ps_key);
15521551
an->ps_key = 0;
15531552
an->key_idx[0] = 0;
15541553
}
@@ -1748,7 +1747,7 @@ static int ath9k_set_key(struct ieee80211_hw *hw,
17481747
}
17491748
break;
17501749
case DISABLE_KEY:
1751-
ath_key_delete(common, key);
1750+
ath_key_delete(common, key->hw_key_idx);
17521751
if (an) {
17531752
for (i = 0; i < ARRAY_SIZE(an->key_idx); i++) {
17541753
if (an->key_idx[i] != key->hw_key_idx)

drivers/net/wireless/ath/key.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -581,38 +581,38 @@ EXPORT_SYMBOL(ath_key_config);
581581
/*
582582
* Delete Key.
583583
*/
584-
void ath_key_delete(struct ath_common *common, struct ieee80211_key_conf *key)
584+
void ath_key_delete(struct ath_common *common, u8 hw_key_idx)
585585
{
586586
/* Leave CCMP and TKIP (main key) configured to avoid disabling
587587
* encryption for potentially pending frames already in a TXQ with the
588588
* keyix pointing to this key entry. Instead, only clear the MAC address
589589
* to prevent RX processing from using this key cache entry.
590590
*/
591-
if (test_bit(key->hw_key_idx, common->ccmp_keymap) ||
592-
test_bit(key->hw_key_idx, common->tkip_keymap))
593-
ath_hw_keysetmac(common, key->hw_key_idx, NULL);
591+
if (test_bit(hw_key_idx, common->ccmp_keymap) ||
592+
test_bit(hw_key_idx, common->tkip_keymap))
593+
ath_hw_keysetmac(common, hw_key_idx, NULL);
594594
else
595-
ath_hw_keyreset(common, key->hw_key_idx);
596-
if (key->hw_key_idx < IEEE80211_WEP_NKID)
595+
ath_hw_keyreset(common, hw_key_idx);
596+
if (hw_key_idx < IEEE80211_WEP_NKID)
597597
return;
598598

599-
clear_bit(key->hw_key_idx, common->keymap);
600-
clear_bit(key->hw_key_idx, common->ccmp_keymap);
601-
if (key->cipher != WLAN_CIPHER_SUITE_TKIP)
599+
clear_bit(hw_key_idx, common->keymap);
600+
clear_bit(hw_key_idx, common->ccmp_keymap);
601+
if (!test_bit(hw_key_idx, common->tkip_keymap))
602602
return;
603603

604-
clear_bit(key->hw_key_idx + 64, common->keymap);
604+
clear_bit(hw_key_idx + 64, common->keymap);
605605

606-
clear_bit(key->hw_key_idx, common->tkip_keymap);
607-
clear_bit(key->hw_key_idx + 64, common->tkip_keymap);
606+
clear_bit(hw_key_idx, common->tkip_keymap);
607+
clear_bit(hw_key_idx + 64, common->tkip_keymap);
608608

609609
if (!(common->crypt_caps & ATH_CRYPT_CAP_MIC_COMBINED)) {
610-
ath_hw_keyreset(common, key->hw_key_idx + 32);
611-
clear_bit(key->hw_key_idx + 32, common->keymap);
612-
clear_bit(key->hw_key_idx + 64 + 32, common->keymap);
610+
ath_hw_keyreset(common, hw_key_idx + 32);
611+
clear_bit(hw_key_idx + 32, common->keymap);
612+
clear_bit(hw_key_idx + 64 + 32, common->keymap);
613613

614-
clear_bit(key->hw_key_idx + 32, common->tkip_keymap);
615-
clear_bit(key->hw_key_idx + 64 + 32, common->tkip_keymap);
614+
clear_bit(hw_key_idx + 32, common->tkip_keymap);
615+
clear_bit(hw_key_idx + 64 + 32, common->tkip_keymap);
616616
}
617617
}
618618
EXPORT_SYMBOL(ath_key_delete);

0 commit comments

Comments
 (0)