1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Sun, 6 Oct 2024 17:34:08 +0200
3 Subject: [PATCH] wifi: mac80211: skip non-uploaded keys in ieee80211_iter_keys
5 Sync iterator conditions with ieee80211_iter_keys_rcu.
7 Fixes: 830af02f24fb ("mac80211: allow driver to iterate keys")
8 Signed-off-by: Felix Fietkau <nbd@nbd.name>
11 --- a/net/mac80211/key.c
12 +++ b/net/mac80211/key.c
13 @@ -987,6 +987,26 @@ void ieee80211_reenable_keys(struct ieee
18 +ieee80211_key_iter(struct ieee80211_hw *hw,
19 + struct ieee80211_vif *vif,
20 + struct ieee80211_key *key,
21 + void (*iter)(struct ieee80211_hw *hw,
22 + struct ieee80211_vif *vif,
23 + struct ieee80211_sta *sta,
24 + struct ieee80211_key_conf *key,
28 + /* skip keys of station in removal process */
29 + if (key->sta && key->sta->removed)
31 + if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE))
33 + iter(hw, vif, key->sta ? &key->sta->sta : NULL,
34 + &key->conf, iter_data);
37 void ieee80211_iter_keys(struct ieee80211_hw *hw,
38 struct ieee80211_vif *vif,
39 void (*iter)(struct ieee80211_hw *hw,
40 @@ -1005,16 +1025,13 @@ void ieee80211_iter_keys(struct ieee8021
42 sdata = vif_to_sdata(vif);
43 list_for_each_entry_safe(key, tmp, &sdata->key_list, list)
44 - iter(hw, &sdata->vif,
45 - key->sta ? &key->sta->sta : NULL,
46 - &key->conf, iter_data);
47 + ieee80211_key_iter(hw, vif, key, iter, iter_data);
49 list_for_each_entry(sdata, &local->interfaces, list)
50 list_for_each_entry_safe(key, tmp,
51 &sdata->key_list, list)
52 - iter(hw, &sdata->vif,
53 - key->sta ? &key->sta->sta : NULL,
54 - &key->conf, iter_data);
55 + ieee80211_key_iter(hw, &sdata->vif, key,
59 EXPORT_SYMBOL(ieee80211_iter_keys);
60 @@ -1031,17 +1048,8 @@ _ieee80211_iter_keys_rcu(struct ieee8021
62 struct ieee80211_key *key;
64 - list_for_each_entry_rcu(key, &sdata->key_list, list) {
65 - /* skip keys of station in removal process */
66 - if (key->sta && key->sta->removed)
68 - if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE))
71 - iter(hw, &sdata->vif,
72 - key->sta ? &key->sta->sta : NULL,
73 - &key->conf, iter_data);
75 + list_for_each_entry_rcu(key, &sdata->key_list, list)
76 + ieee80211_key_iter(hw, &sdata->vif, key, iter, iter_data);
79 void ieee80211_iter_keys_rcu(struct ieee80211_hw *hw,