Skip to contentSkip to conversation

bridge: kernel panic when unloading bridge module

PATCH Applied Stephen Hemminger 2 participants 2 messages Apr 29, 2008 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 20080428172809.7f814ed5@extreme

#1 lore raw

PATCH 2/2 bridge: kernel panic when unloading bridge module

There is a race condition when unloading bridge and netfilter.

The problem happens if __fake_rtable is in use by a skb coming in, while someone starts to unload bridge.ko. br_netfilter_fini() is called at the beginning of unload in br_deinit() while skbs still are being forwarded and transferred to local ip stack. Thus there is a possibility of the __fake_rtable pointer not being removed in a skb that goes up to ip stack. This results in a kernel panic, as ip_rcv() calls the input-function of __fake_rtable, which is NULL.

Moving the call of br_netfilter_fini() to the end of br_deinit() solves the problem.

---
 net/bridge/br.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
net/bridge/br.c +1 -1
@@ -76,7 +76,6 @@ static void __exit br_deinit(void)
 	rcu_assign_pointer(br_stp_sap->rcv_func, NULL);
 
 	br_netlink_fini();
-	br_netfilter_fini();
 	unregister_netdevice_notifier(&br_device_notifier);
 	brioctl_set(NULL);
 
@@ -84,6 +83,7 @@ static void __exit br_deinit(void)
 
 	synchronize_net();
 
+	br_netfilter_fini();
 	llc_sap_put(br_stp_sap);
 	br_fdb_get_hook = NULL;
 	br_fdb_put_hook = NULL;
maintainer
#2 lore raw

From: Stephen Hemminger <[email protected]>
Date: Mon, 28 Apr 2008 17:29:07 -0700

Quoted 12 lines

There is a race condition when unloading bridge and netfilter.

The problem happens if __fake_rtable is in use by a skb coming in, while someone starts to unload bridge.ko. br_netfilter_fini() is called at the beginning of unload in br_deinit() while skbs still are being forwarded and transferred to local ip stack. Thus there is a possibility of the __fake_rtable pointer not being removed in a skb that goes up to ip stack. This results in a kernel panic, as ip_rcv() calls the input-function of __fake_rtable, which is NULL.

Quoted 5 lines

Moving the call of br_netfilter_fini() to the end of br_deinit() solves the problem.

Also applied, thanks.