[v2] batman-adv: Always synchronize rcu's on module shutdown

Message ID 1283777124-26316-1-git-send-email-sven.eckelmann@gmx.de (mailing list archive)
State Accepted, archived
Headers

Commit Message

Sven Eckelmann Sept. 6, 2010, 12:45 p.m. UTC
  From: Linus Lüssing <linus.luessing@web.de>

During the module shutdown procedure in batman_exit(), a rcu callback is
being scheduled (batman_exit -> hardif_remove_interfaces ->
hardif_remove_interfae -> call_rcu). However, when the kernel unloads
the module, the rcu callback might not have been executed yet, resulting
in a "unable to handle kernel paging request" in __rcu_process_callback
afterwards, causing the kernel to freeze.

The synchronize_net and synchronize_rcu in mesh_free are currently
called before the call_rcu in hardif_remove_interface and have no real
effect on it.

Therefore, we should always flush all rcu callback functions scheduled
during the shutdown procedure using synchronize_net. The call to
synchronize_rcu can be omitted because synchronize_net already calls it.

Signed-off-by: Linus Lüssing <linus.luessing@web.de>
Acked-by: Sven Eckelmann <sven.eckelmann@gmx.de>
---
 batman-adv/main.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
  

Comments

Marek Lindner Sept. 6, 2010, 2:09 p.m. UTC | #1
On Monday 06 September 2010 14:45:24 Sven Eckelmann wrote:
> Therefore, we should always flush all rcu callback functions scheduled
> during the shutdown procedure using synchronize_net. The call to
> synchronize_rcu can be omitted because synchronize_net already calls it.

Applied in revision 1788.

Thanks,
Marek
  

Patch

diff --git a/batman-adv/main.c b/batman-adv/main.c
index 209a46b..e8acb46 100644
--- a/batman-adv/main.c
+++ b/batman-adv/main.c
@@ -73,6 +73,8 @@  static void __exit batman_exit(void)
 	flush_workqueue(bat_event_workqueue);
 	destroy_workqueue(bat_event_workqueue);
 	bat_event_workqueue = NULL;
+
+	synchronize_net();
 }
 
 int mesh_init(struct net_device *soft_iface)
@@ -135,9 +137,6 @@  void mesh_free(struct net_device *soft_iface)
 	hna_local_free(bat_priv);
 	hna_global_free(bat_priv);
 
-	synchronize_net();
-
-	synchronize_rcu();
 	atomic_set(&bat_priv->mesh_state, MESH_INACTIVE);
 }