Skip to contentSkip to conversation

mac80211: fix AP/VLAN PS buffer race

PATCH In review Johannes Berg 2 participants 3 messages Sep 20, 2011 mac80211

lore
Share & tools
lore

Johannes Berg

author maintainer
#0 lore raw

PATCH 1/1 mac80211: fix AP/VLAN PS buffer race

From: Johannes Berg <[email protected]>

When an AP interface is removed without the AP/VLAN interfaces having been removed before already, the AP-VLAN interface might still have sleeping stations and buffer multicast frames which will happen on the AP interface. Thus, we need to remove AP/VLAN interfaces before purging buffered broadcast frames.

---
 net/mac80211/iface.c |   10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
net/mac80211/iface.c +4 -6
@@ -460,17 +460,15 @@ static void ieee80211_do_stop(struct iee
 		synchronize_rcu();
 		kfree(old_beacon);
 
-		/* free all potentially still buffered bcast frames */
-		while ((skb = skb_dequeue(&sdata->u.ap.ps_bc_buf))) {
-			local->total_ps_buffered--;
-			dev_kfree_skb(skb);
-		}
-
 		/* down all dependent devices, that is VLANs */
 		list_for_each_entry_safe(vlan, tmpsdata, &sdata->u.ap.vlans,
 					 u.vlan.list)
 			dev_close(vlan->dev);
 		WARN_ON(!list_empty(&sdata->u.ap.vlans));
+
+		/* free all potentially still buffered bcast frames */
+		local->total_ps_buffered -= skb_queue_len(&sdata->u.ap.ps_bc_buf);
+		skb_queue_purge(&sdata->u.ap.ps_bc_buf);
 	}
 
 	if (going_down)
#1 lore raw
Quoted 11 lines · Johannes Berg

From: Johannes Berg <[email protected]>

When an AP interface is removed without the AP/VLAN interfaces having been removed before already, the AP-VLAN interface might still have sleeping stations and buffer multicast frames which will happen on the AP interface. Thus, we need to remove AP/VLAN interfaces before purging buffered broadcast frames.

Curious, what was happening with the inverse?

Luis

author maintainer
#2 lore raw
Quoted 12 lines · Luis R. Rodriguez
Quoted 10 lines · Johannes Berg

From: Johannes Berg <[email protected]>

When an AP interface is removed without the AP/VLAN interfaces having been removed before already, the AP-VLAN interface might still have sleeping stations and buffer multicast frames which will happen on the AP interface. Thus, we need to remove AP/VLAN interfaces before purging buffered broadcast frames.

Quoted 3 lines
Quoted 1 line

Curious, what was happening with the inverse?

I never ran into this -- purely by code inspection. What could've happened is that frames are still queued for an interface that's dead, probably just causing skb leaks.

johannes