From: "Linus Lüssing" <linus.luessing@web.de>
To: b.a.t.m.a.n@lists.open-mesh.org
Subject: [B.A.T.M.A.N.] [PATCH 2/2] batman-adv: Fix general protection fault in batadv_tt_global_del_orig()
Date: Sun, 17 Mar 2013 05:44:58 +0100 [thread overview]
Message-ID: <1363495498-17830-2-git-send-email-linus.luessing@web.de> (raw)
In-Reply-To: <1363495498-17830-1-git-send-email-linus.luessing@web.de>
On shutdown a race condition where we access a just freed global TT hash
might occure. batadv_orig_node_free_rcu() callbacks might have been
scheduled (especially during the shutdown procedure) and unfortunately
batadv_tt_global_table_free() does not wait for them to finish first
before freeing the global TT hash.
This potentially results in a general protection fault in
batadv_tt_global_del_orig(), called via a batadv_orig_node_free_rcu()
callback, which tries to access the just freed global TT hash.
This patch tries to fix this by waiting for any just scheduled
batadv_orig_node_free_rcu() to finish via an extra rcu_barrier() call
before freeing the global TT hash. And by moving the TT freeing call to
the end of the batman cleanup routines.
Signed-off-by: Linus Lüssing <linus.luessing@web.de>
diff --git a/main.c b/main.c
index 62b1f89..8663d97 100644
--- a/main.c
+++ b/main.c
@@ -166,12 +166,13 @@ void batadv_mesh_free(struct net_device *soft_iface)
batadv_originator_free(bat_priv);
batadv_nc_free(bat_priv);
- batadv_tt_free(bat_priv);
-
batadv_bla_free(bat_priv);
batadv_dat_free(bat_priv);
+ /* Don't call any batadv_orig_node_free_ref() after me */
+ batadv_tt_free(bat_priv);
+
free_percpu(bat_priv->bat_counters);
atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
diff --git a/translation-table.c b/translation-table.c
index ee91cc1..279f0fd 100644
--- a/translation-table.c
+++ b/translation-table.c
@@ -1315,6 +1315,10 @@ static void batadv_tt_global_table_free(struct batadv_priv *bat_priv)
spin_unlock_bh(list_lock);
}
+ /* Wait for any batadv_orig_node_free_rcu() to finish,
+ * they access the to be freed global TT hash */
+ rcu_barrier();
+
batadv_hash_destroy(hash);
bat_priv->tt.global_hash = NULL;
--
1.7.10.4
next prev parent reply other threads:[~2013-03-17 4:44 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-17 2:30 [B.A.T.M.A.N.] [PATCH] batman-adv: Fix general protection fault in batadv_tt_global_del_orig() Linus Lüssing
2013-03-17 2:42 ` Linus Lüssing
2013-03-17 3:22 ` "Linus Lüssing"
2013-03-17 4:44 ` [B.A.T.M.A.N.] [PATCH 1/2] batman-adv: Fix rcu_barrier() miss due to double call_rcu() in TT code Linus Lüssing
2013-03-17 4:44 ` Linus Lüssing [this message]
2013-03-30 13:16 ` [B.A.T.M.A.N.] [PATCH 2/2] batman-adv: Fix general protection fault in batadv_tt_global_del_orig() Antonio Quartulli
2013-04-17 12:58 ` Antonio Quartulli
2013-03-30 13:10 ` [B.A.T.M.A.N.] [PATCH 1/2] batman-adv: Fix rcu_barrier() miss due to double call_rcu() in TT code Antonio Quartulli
2013-04-03 1:25 ` [B.A.T.M.A.N.] [PATCHv2 " Linus Lüssing
2013-04-03 8:11 ` Antonio Quartulli
2013-04-15 13:48 ` Marek Lindner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1363495498-17830-2-git-send-email-linus.luessing@web.de \
--to=linus.luessing@web.de \
--cc=b.a.t.m.a.n@lists.open-mesh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.