* [PATCH wireless] wifi: mac80211: skip non-uploaded keys in ieee80211_iter_keys
@ 2024-10-06 15:36 Felix Fietkau
2024-10-15 9:13 ` Kalle Valo
0 siblings, 1 reply; 4+ messages in thread
From: Felix Fietkau @ 2024-10-06 15:36 UTC (permalink / raw)
To: linux-wireless; +Cc: johannes
Sync iterator conditions with ieee80211_iter_keys_rcu.
Fixes: 830af02f24fb ("mac80211: allow driver to iterate keys")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
net/mac80211/key.c | 42 +++++++++++++++++++++++++-----------------
1 file changed, 25 insertions(+), 17 deletions(-)
diff --git a/net/mac80211/key.c b/net/mac80211/key.c
index eecdd2265eaa..e45b5f56c405 100644
--- a/net/mac80211/key.c
+++ b/net/mac80211/key.c
@@ -987,6 +987,26 @@ void ieee80211_reenable_keys(struct ieee80211_sub_if_data *sdata)
}
}
+static void
+ieee80211_key_iter(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif,
+ struct ieee80211_key *key,
+ void (*iter)(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif,
+ struct ieee80211_sta *sta,
+ struct ieee80211_key_conf *key,
+ void *data),
+ void *iter_data)
+{
+ /* skip keys of station in removal process */
+ if (key->sta && key->sta->removed)
+ return;
+ if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE))
+ return;
+ iter(hw, vif, key->sta ? &key->sta->sta : NULL,
+ &key->conf, iter_data);
+}
+
void ieee80211_iter_keys(struct ieee80211_hw *hw,
struct ieee80211_vif *vif,
void (*iter)(struct ieee80211_hw *hw,
@@ -1005,16 +1025,13 @@ void ieee80211_iter_keys(struct ieee80211_hw *hw,
if (vif) {
sdata = vif_to_sdata(vif);
list_for_each_entry_safe(key, tmp, &sdata->key_list, list)
- iter(hw, &sdata->vif,
- key->sta ? &key->sta->sta : NULL,
- &key->conf, iter_data);
+ ieee80211_key_iter(hw, vif, key, iter, iter_data);
} else {
list_for_each_entry(sdata, &local->interfaces, list)
list_for_each_entry_safe(key, tmp,
&sdata->key_list, list)
- iter(hw, &sdata->vif,
- key->sta ? &key->sta->sta : NULL,
- &key->conf, iter_data);
+ ieee80211_key_iter(hw, &sdata->vif, key,
+ iter, iter_data);
}
}
EXPORT_SYMBOL(ieee80211_iter_keys);
@@ -1031,17 +1048,8 @@ _ieee80211_iter_keys_rcu(struct ieee80211_hw *hw,
{
struct ieee80211_key *key;
- list_for_each_entry_rcu(key, &sdata->key_list, list) {
- /* skip keys of station in removal process */
- if (key->sta && key->sta->removed)
- continue;
- if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE))
- continue;
-
- iter(hw, &sdata->vif,
- key->sta ? &key->sta->sta : NULL,
- &key->conf, iter_data);
- }
+ list_for_each_entry_rcu(key, &sdata->key_list, list)
+ ieee80211_key_iter(hw, &sdata->vif, key, iter, iter_data);
}
void ieee80211_iter_keys_rcu(struct ieee80211_hw *hw,
--
2.46.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH wireless] wifi: mac80211: skip non-uploaded keys in ieee80211_iter_keys
2024-10-06 15:36 [PATCH wireless] wifi: mac80211: skip non-uploaded keys in ieee80211_iter_keys Felix Fietkau
@ 2024-10-15 9:13 ` Kalle Valo
2024-10-15 9:42 ` Felix Fietkau
0 siblings, 1 reply; 4+ messages in thread
From: Kalle Valo @ 2024-10-15 9:13 UTC (permalink / raw)
To: Felix Fietkau; +Cc: linux-wireless, johannes
Felix Fietkau <nbd@nbd.name> writes:
> Sync iterator conditions with ieee80211_iter_keys_rcu.
>
> Fixes: 830af02f24fb ("mac80211: allow driver to iterate keys")
> Signed-off-by: Felix Fietkau <nbd@nbd.name>
I see this is already applied but why we need this? Please include a
description of the bug in the commit message. That's too late now but if
you provide one via email I can include it in the pull request.
--
https://patchwork.kernel.org/project/linux-wireless/list/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH wireless] wifi: mac80211: skip non-uploaded keys in ieee80211_iter_keys
2024-10-15 9:13 ` Kalle Valo
@ 2024-10-15 9:42 ` Felix Fietkau
2024-10-16 9:41 ` Kalle Valo
0 siblings, 1 reply; 4+ messages in thread
From: Felix Fietkau @ 2024-10-15 9:42 UTC (permalink / raw)
To: Kalle Valo; +Cc: linux-wireless, johannes
On 15.10.24 11:13, Kalle Valo wrote:
> Felix Fietkau <nbd@nbd.name> writes:
>
>> Sync iterator conditions with ieee80211_iter_keys_rcu.
>>
>> Fixes: 830af02f24fb ("mac80211: allow driver to iterate keys")
>> Signed-off-by: Felix Fietkau <nbd@nbd.name>
>
> I see this is already applied but why we need this? Please include a
> description of the bug in the commit message. That's too late now but if
> you provide one via email I can include it in the pull request.
I needed the key iterator for not yet published mt7996 work, and while
reading the code found the inconsistency, that (unlike the RCU version)
it could pass keys that weren't added to the driver yet.
I didn't see any specific driver bugs, but the mac80211 code didn't make
sense to me during review, so I fixed it.
- Felix
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH wireless] wifi: mac80211: skip non-uploaded keys in ieee80211_iter_keys
2024-10-15 9:42 ` Felix Fietkau
@ 2024-10-16 9:41 ` Kalle Valo
0 siblings, 0 replies; 4+ messages in thread
From: Kalle Valo @ 2024-10-16 9:41 UTC (permalink / raw)
To: Felix Fietkau; +Cc: linux-wireless, johannes
Felix Fietkau <nbd@nbd.name> writes:
> On 15.10.24 11:13, Kalle Valo wrote:
>> Felix Fietkau <nbd@nbd.name> writes:
>>
>>> Sync iterator conditions with ieee80211_iter_keys_rcu.
>>>
>>> Fixes: 830af02f24fb ("mac80211: allow driver to iterate keys")
>>> Signed-off-by: Felix Fietkau <nbd@nbd.name>
>> I see this is already applied but why we need this? Please include a
>> description of the bug in the commit message. That's too late now but if
>> you provide one via email I can include it in the pull request.
>
> I needed the key iterator for not yet published mt7996 work, and while
> reading the code found the inconsistency, that (unlike the RCU
> version) it could pass keys that weren't added to the driver yet.
> I didn't see any specific driver bugs, but the mac80211 code didn't
> make sense to me during review, so I fixed it.
Ah, if this is just a theoretical fix I don't mention anything about
this in the pull request. Thanks.
--
https://patchwork.kernel.org/project/linux-wireless/list/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-10-16 9:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-06 15:36 [PATCH wireless] wifi: mac80211: skip non-uploaded keys in ieee80211_iter_keys Felix Fietkau
2024-10-15 9:13 ` Kalle Valo
2024-10-15 9:42 ` Felix Fietkau
2024-10-16 9:41 ` Kalle Valo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).