Skip to content

Commit c9cf951

Browse files
nbd168gregkh
authored andcommitted
wifi: mac80211: skip non-uploaded keys in ieee80211_iter_keys
[ Upstream commit 52009b4 ] Sync iterator conditions with ieee80211_iter_keys_rcu. Fixes: 830af02 ("mac80211: allow driver to iterate keys") Signed-off-by: Felix Fietkau <nbd@nbd.name> Link: https://patch.msgid.link/20241006153630.87885-1-nbd@nbd.name Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 339df13 commit c9cf951

1 file changed

Lines changed: 25 additions & 17 deletions

File tree

net/mac80211/key.c

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,26 @@ void ieee80211_reset_crypto_tx_tailroom(struct ieee80211_sub_if_data *sdata)
777777
mutex_unlock(&sdata->local->key_mtx);
778778
}
779779

780+
static void
781+
ieee80211_key_iter(struct ieee80211_hw *hw,
782+
struct ieee80211_vif *vif,
783+
struct ieee80211_key *key,
784+
void (*iter)(struct ieee80211_hw *hw,
785+
struct ieee80211_vif *vif,
786+
struct ieee80211_sta *sta,
787+
struct ieee80211_key_conf *key,
788+
void *data),
789+
void *iter_data)
790+
{
791+
/* skip keys of station in removal process */
792+
if (key->sta && key->sta->removed)
793+
return;
794+
if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE))
795+
return;
796+
iter(hw, vif, key->sta ? &key->sta->sta : NULL,
797+
&key->conf, iter_data);
798+
}
799+
780800
void ieee80211_iter_keys(struct ieee80211_hw *hw,
781801
struct ieee80211_vif *vif,
782802
void (*iter)(struct ieee80211_hw *hw,
@@ -796,16 +816,13 @@ void ieee80211_iter_keys(struct ieee80211_hw *hw,
796816
if (vif) {
797817
sdata = vif_to_sdata(vif);
798818
list_for_each_entry_safe(key, tmp, &sdata->key_list, list)
799-
iter(hw, &sdata->vif,
800-
key->sta ? &key->sta->sta : NULL,
801-
&key->conf, iter_data);
819+
ieee80211_key_iter(hw, vif, key, iter, iter_data);
802820
} else {
803821
list_for_each_entry(sdata, &local->interfaces, list)
804822
list_for_each_entry_safe(key, tmp,
805823
&sdata->key_list, list)
806-
iter(hw, &sdata->vif,
807-
key->sta ? &key->sta->sta : NULL,
808-
&key->conf, iter_data);
824+
ieee80211_key_iter(hw, &sdata->vif, key,
825+
iter, iter_data);
809826
}
810827
mutex_unlock(&local->key_mtx);
811828
}
@@ -823,17 +840,8 @@ _ieee80211_iter_keys_rcu(struct ieee80211_hw *hw,
823840
{
824841
struct ieee80211_key *key;
825842

826-
list_for_each_entry_rcu(key, &sdata->key_list, list) {
827-
/* skip keys of station in removal process */
828-
if (key->sta && key->sta->removed)
829-
continue;
830-
if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE))
831-
continue;
832-
833-
iter(hw, &sdata->vif,
834-
key->sta ? &key->sta->sta : NULL,
835-
&key->conf, iter_data);
836-
}
843+
list_for_each_entry_rcu(key, &sdata->key_list, list)
844+
ieee80211_key_iter(hw, &sdata->vif, key, iter, iter_data);
837845
}
838846

839847
void ieee80211_iter_keys_rcu(struct ieee80211_hw *hw,

0 commit comments

Comments
 (0)