Patchwork [next,2/2] batman-adv: fix global protection fault during soft_iface destruction

login
register
mail settings
Submitter Antonio Quartulli
Date April 19, 2013, 9:04 a.m.
Message ID <1366362292-22961-3-git-send-email-ordex@autistici.org>
Download mbox | patch
Permalink /patch/237880/
State Accepted
Delegated to: David Miller
Headers show

Comments

Antonio Quartulli - April 19, 2013, 9:04 a.m.
batadv_mesh_free() schedules some RCU callbacks which need the bat_priv struct
to do their jobs, while free_netdev(), which is called immediately after, is
destroying the private data.

Put an rcu_barrier() in the middle so that free_netdev() is invoked only after
all the callbacks returned.

This bug has been introduced by ab8f433dd39be94e8617cff2dfe9f7eca162eb15
("batman-adv: Move deinitialization of soft-interface to destructor")

Signed-off-by: Antonio Quartulli <ordex@autistici.org>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
---
 net/batman-adv/soft-interface.c | 7 +++++++
 1 file changed, 7 insertions(+)
David Miller - April 23, 2013, 12:41 a.m.
From: Antonio Quartulli <ordex@autistici.org>
Date: Fri, 19 Apr 2013 11:04:52 +0200

> batadv_mesh_free() schedules some RCU callbacks which need the bat_priv struct
> to do their jobs, while free_netdev(), which is called immediately after, is
> destroying the private data.
> 
> Put an rcu_barrier() in the middle so that free_netdev() is invoked only after
> all the callbacks returned.
> 
> This bug has been introduced by ab8f433dd39be94e8617cff2dfe9f7eca162eb15
> ("batman-adv: Move deinitialization of soft-interface to destructor")
> 
> Signed-off-by: Antonio Quartulli <ordex@autistici.org>
> Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>

Applied.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index 403b8c4..6f20d33 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -582,6 +582,13 @@  static void batadv_softif_free(struct net_device *dev)
 {
 	batadv_debugfs_del_meshif(dev);
 	batadv_mesh_free(dev);
+
+	/* some scheduled RCU callbacks need the bat_priv struct to accomplish
+	 * their tasks. Wait for them all to be finished before freeing the
+	 * netdev and its private data (bat_priv)
+	 */
+	rcu_barrier();
+
 	free_netdev(dev);
 }