2013-02-28 22:19:36

by Johannes Berg

[permalink] [raw]
Subject: [PATCH 1/2] mac80211: flush keys when stopping AP

From: Johannes Berg <[email protected]>

Since hostapd will remove keys this isn't usually
an issue, but we shouldn't leak keys to the next
BSS started on the same interface. For VLANs this
also fixes a bug, keys that aren't removed would
otherwise be leaked.

Signed-off-by: Johannes Berg <[email protected]>
---
net/mac80211/cfg.c | 5 ++++-
net/mac80211/iface.c | 2 +-
2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 64da5a4..3ba614d 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -1035,9 +1035,12 @@ static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev)
sta_info_flush_defer(vlan);
sta_info_flush_defer(sdata);
rcu_barrier();
- list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
+ list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) {
sta_info_flush_cleanup(vlan);
+ ieee80211_free_keys(vlan);
+ }
sta_info_flush_cleanup(sdata);
+ ieee80211_free_keys(sdata);

sdata->vif.bss_conf.enable_beacon = false;
clear_bit(SDATA_STATE_OFFCHANNEL_BEACON_STOPPED, &sdata->state);
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index feda9fb..74228d9 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -836,7 +836,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,

/*
* Free all remaining keys, there shouldn't be any,
- * except maybe group keys in AP more or WDS?
+ * except maybe in WDS mode?
*/
ieee80211_free_keys(sdata);

--
1.8.0



2013-02-28 22:19:36

by Johannes Berg

[permalink] [raw]
Subject: [PATCH 2/2] mac80211: simplify AP interface stop

From: Johannes Berg <[email protected]>

For AP interfaces, there's no need to flush stations
or keys again when the interface is stopped as already
happened when the BSS was stopped on the interface.

Signed-off-by: Johannes Berg <[email protected]>
---
net/mac80211/iface.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index 74228d9..6c60711 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -832,14 +832,16 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
rcu_barrier();
sta_info_flush_cleanup(sdata);

- skb_queue_purge(&sdata->skb_queue);
-
/*
* Free all remaining keys, there shouldn't be any,
* except maybe in WDS mode?
*/
ieee80211_free_keys(sdata);

+ /* fall through */
+ case NL80211_IFTYPE_AP:
+ skb_queue_purge(&sdata->skb_queue);
+
drv_remove_interface_debugfs(local, sdata);

if (going_down)
--
1.8.0


2013-03-04 15:35:22

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH 1/2] mac80211: flush keys when stopping AP

On Thu, 2013-02-28 at 23:19 +0100, Johannes Berg wrote:
> From: Johannes Berg <[email protected]>
>
> Since hostapd will remove keys this isn't usually
> an issue, but we shouldn't leak keys to the next
> BSS started on the same interface. For VLANs this
> also fixes a bug, keys that aren't removed would
> otherwise be leaked.

Applied both.

johannes