b426d68c326fd02599a7310e6ed237ae8e2ae251
[openwrt/openwrt.git] /
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
4
5 Sync iterator conditions with ieee80211_iter_keys_rcu.
6
7 Fixes: 830af02f24fb ("mac80211: allow driver to iterate keys")
8 Signed-off-by: Felix Fietkau <nbd@nbd.name>
9 ---
10
11 --- a/net/mac80211/key.c
12 +++ b/net/mac80211/key.c
13 @@ -987,6 +987,26 @@ void ieee80211_reenable_keys(struct ieee
14 }
15 }
16
17 +static void
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,
25 + void *data),
26 + void *iter_data)
27 +{
28 + /* skip keys of station in removal process */
29 + if (key->sta && key->sta->removed)
30 + return;
31 + if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE))
32 + return;
33 + iter(hw, vif, key->sta ? &key->sta->sta : NULL,
34 + &key->conf, iter_data);
35 +}
36 +
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
41 if (vif) {
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);
48 } else {
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,
56 + iter, iter_data);
57 }
58 }
59 EXPORT_SYMBOL(ieee80211_iter_keys);
60 @@ -1031,17 +1048,8 @@ _ieee80211_iter_keys_rcu(struct ieee8021
61 {
62 struct ieee80211_key *key;
63
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)
67 - continue;
68 - if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE))
69 - continue;
70 -
71 - iter(hw, &sdata->vif,
72 - key->sta ? &key->sta->sta : NULL,
73 - &key->conf, iter_data);
74 - }
75 + list_for_each_entry_rcu(key, &sdata->key_list, list)
76 + ieee80211_key_iter(hw, &sdata->vif, key, iter, iter_data);
77 }
78
79 void ieee80211_iter_keys_rcu(struct ieee80211_hw *hw,