Skip to contentSkip to conversation

d80211: Fix __ieee80211_if_del on live interfaces

PATCH Applied Michael Wu 3 participants 3 messages Jan 10, 2007

Subsystems (2)
lore
Share & tools
lore

Michael Wu

author
#0 lore raw

PATCH 1/1 d80211: Fix __ieee80211_if_del on live interfaces

d80211: Fix __ieee80211_if_del on live interfaces

ieee80211_if_reinit is called in __ieee80211_if_del, which clears the contents of sdata->u. After that, unregister_netdevice is called. If the interface is still up, unregister_netdevice will end up calling dev->stop, and dev->stop expects the contents of sdata->u to be valid. Bad things typically happen at this point.

This patch fixes that by setting dev->uninit to ieee80211_if_reinit and eliminating the call to ieee80211_if_reinit in __ieee80211_if_del. This allows ieee80211_if_reinit to be called at a safer time. It also allows the removal of the call to ieee80211_if_shutdown in ieee80211_if_reinit because ieee80211_if_reinit now will never be called while the interface is up.

---

 net/d80211/ieee80211.c       |    2 ++
 net/d80211/ieee80211_iface.c |    4 ----
 2 files changed, 2 insertions(+), 4 deletions(-)
net/d80211/ieee80211.c +2 -0
index 964fe45..2f1dce5 100644
@@ -4324,6 +4324,7 @@ void ieee80211_if_setup(struct net_devic
 	dev->open = ieee80211_open;
 	dev->stop = ieee80211_stop;
 	dev->tx_queue_len = 0;
+	dev->uninit = ieee80211_if_reinit;
 	dev->destructor = ieee80211_if_free;
 }
 
@@ -4338,6 +4339,7 @@ void ieee80211_if_mgmt_setup(struct net_
 	dev->type = ARPHRD_IEEE80211_PRISM;
 	dev->hard_header_parse = header_parse_80211;
 	dev->tx_queue_len = 0;
+	dev->uninit = ieee80211_if_reinit;
 	dev->destructor = ieee80211_if_free;
 }
 
net/d80211/ieee80211_iface.c +0 -4
index cac0dd5..3b2d259 100644
@@ -234,9 +234,6 @@ void ieee80211_if_reinit(struct net_devi
 		sdata->keys[i] = NULL;
 	}
 
-	/* Shouldn't be necessary but won't hurt */
-	ieee80211_if_shutdown(dev);
-
 	switch (sdata->type) {
 	case IEEE80211_IF_TYPE_AP: {
 		/* Remove all virtual interfaces that use this BSS
@@ -311,7 +308,6 @@ void __ieee80211_if_del(struct ieee80211
 {
 	struct net_device *dev = sdata->dev;
 
-	ieee80211_if_reinit(dev);
 	list_del(&sdata->list);
 	ieee80211_sysfs_remove_netdevice(dev);
 	unregister_netdevice(dev);
#1 lore raw
Quoted 8 lines · Michael Wu

d80211: Fix __ieee80211_if_del on live interfaces

ieee80211_if_reinit is called in __ieee80211_if_del, which clears the contents of sdata->u. After that, unregister_netdevice is called. If the interface is still up, unregister_netdevice will end up calling dev->stop, and dev->stop expects the contents of sdata->u to be valid. Bad things typically happen at this point.

Quoted 8 lines

This patch fixes that by setting dev->uninit to ieee80211_if_reinit and eliminating the call to ieee80211_if_reinit in __ieee80211_if_del. This allows ieee80211_if_reinit to be called at a safer time. It also allows the removal of the call to ieee80211_if_shutdown in ieee80211_if_reinit because ieee80211_if_reinit now will never be called while the interface is up.

ACK, this fixes the lockup bug I recently reported.

Quoted 49 lines

---

 net/d80211/ieee80211.c       |    2 ++
 net/d80211/ieee80211_iface.c |    4 ----
 2 files changed, 2 insertions(+), 4 deletions(-)
net/d80211/ieee80211.c +2 -0
index 964fe45..2f1dce5 100644
@@ -4324,6 +4324,7 @@ void ieee80211_if_setup(struct net_devic
 	dev->open = ieee80211_open;
 	dev->stop = ieee80211_stop;
 	dev->tx_queue_len = 0;
+	dev->uninit = ieee80211_if_reinit;
 	dev->destructor = ieee80211_if_free;
 }
 
@@ -4338,6 +4339,7 @@ void ieee80211_if_mgmt_setup(struct net_
 	dev->type = ARPHRD_IEEE80211_PRISM;
 	dev->hard_header_parse = header_parse_80211;
 	dev->tx_queue_len = 0;
+	dev->uninit = ieee80211_if_reinit;
 	dev->destructor = ieee80211_if_free;
 }
 
net/d80211/ieee80211_iface.c +0 -4
index cac0dd5..3b2d259 100644
@@ -234,9 +234,6 @@ void ieee80211_if_reinit(struct net_devi
 		sdata->keys[i] = NULL;
 	}
 
-	/* Shouldn't be necessary but won't hurt */
-	ieee80211_if_shutdown(dev);
-
 	switch (sdata->type) {
 	case IEEE80211_IF_TYPE_AP: {
 		/* Remove all virtual interfaces that use this BSS
@@ -311,7 +308,6 @@ void __ieee80211_if_del(struct ieee80211
 {
 	struct net_device *dev = sdata->dev;
 
-	ieee80211_if_reinit(dev);
 	list_del(&sdata->list);
 	ieee80211_sysfs_remove_netdevice(dev);
 	unregister_netdevice(dev);
Signature · 1 line
Greetings Michael.
Applied
#2 lore raw
In reply to Michael Wu
Quoted 6 lines · Michael Wu

This patch fixes that by setting dev->uninit to ieee80211_if_reinit and eliminating the call to ieee80211_if_reinit in __ieee80211_if_del. This allows ieee80211_if_reinit to be called at a safer time. It also allows the removal of the call to ieee80211_if_shutdown in ieee80211_if_reinit because ieee80211_if_reinit now will never be called while the interface is up.

Applied to my tree, thanks for the patch. (And I can confirm it fixes the problem reported by Michael Buesch too.)

Jiri

Signature · 2 lines
Jiri Benc
SUSE Labs