All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] mac80211: mesh: do mesh rhashtable walks with BHs disabled
@ 2019-02-05 20:22 Johannes Berg
  0 siblings, 0 replies; only message in thread
From: Johannes Berg @ 2019-02-05 20:22 UTC (permalink / raw)
  To: linux-wireless; +Cc: Johannes Berg

From: Johannes Berg <johannes.berg@intel.com>

Since we do some walks from *within* softirq context and the
rhashtable code just uses a plain spin_lock(), we need to
disable softirqs for other walks that are not within softirq
context to avoid a potential deadlock (taking a softirq that
takes the spinlock while inside the spinlock from regular
process context.)

Reported-by: Jouni Malinen <j@w1.fi>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 net/mac80211/mesh_pathtbl.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/net/mac80211/mesh_pathtbl.c b/net/mac80211/mesh_pathtbl.c
index a5125624a76d..f235a05b8226 100644
--- a/net/mac80211/mesh_pathtbl.c
+++ b/net/mac80211/mesh_pathtbl.c
@@ -574,9 +574,11 @@ void mesh_path_flush_by_nexthop(struct sta_info *sta)
 	struct rhashtable_iter iter;
 	int ret;
 
+	local_bh_disable();
+
 	ret = rhashtable_walk_init(&tbl->rhead, &iter, GFP_ATOMIC);
 	if (ret)
-		return;
+		goto out;
 
 	rhashtable_walk_start(&iter);
 
@@ -592,6 +594,8 @@ void mesh_path_flush_by_nexthop(struct sta_info *sta)
 
 	rhashtable_walk_stop(&iter);
 	rhashtable_walk_exit(&iter);
+out:
+	local_bh_enable();
 }
 
 static void mpp_flush_by_proxy(struct ieee80211_sub_if_data *sdata,
@@ -602,9 +606,10 @@ static void mpp_flush_by_proxy(struct ieee80211_sub_if_data *sdata,
 	struct rhashtable_iter iter;
 	int ret;
 
+	local_bh_disable();
 	ret = rhashtable_walk_init(&tbl->rhead, &iter, GFP_ATOMIC);
 	if (ret)
-		return;
+		goto out;
 
 	rhashtable_walk_start(&iter);
 
@@ -620,6 +625,8 @@ static void mpp_flush_by_proxy(struct ieee80211_sub_if_data *sdata,
 
 	rhashtable_walk_stop(&iter);
 	rhashtable_walk_exit(&iter);
+out:
+	local_bh_enable();
 }
 
 static void table_flush_by_iface(struct mesh_table *tbl)
@@ -628,9 +635,10 @@ static void table_flush_by_iface(struct mesh_table *tbl)
 	struct rhashtable_iter iter;
 	int ret;
 
+	local_bh_disable();
 	ret = rhashtable_walk_init(&tbl->rhead, &iter, GFP_ATOMIC);
 	if (ret)
-		return;
+		goto out;
 
 	rhashtable_walk_start(&iter);
 
@@ -644,6 +652,8 @@ static void table_flush_by_iface(struct mesh_table *tbl)
 
 	rhashtable_walk_stop(&iter);
 	rhashtable_walk_exit(&iter);
+out:
+	local_bh_enable();
 }
 
 /**
@@ -857,9 +867,10 @@ void mesh_path_tbl_expire(struct ieee80211_sub_if_data *sdata,
 	struct rhashtable_iter iter;
 	int ret;
 
+	local_bh_disable();
 	ret = rhashtable_walk_init(&tbl->rhead, &iter, GFP_KERNEL);
 	if (ret)
-		return;
+		goto out;
 
 	rhashtable_walk_start(&iter);
 
@@ -876,6 +887,8 @@ void mesh_path_tbl_expire(struct ieee80211_sub_if_data *sdata,
 
 	rhashtable_walk_stop(&iter);
 	rhashtable_walk_exit(&iter);
+out:
+	local_bh_enable();
 }
 
 void mesh_path_expire(struct ieee80211_sub_if_data *sdata)
-- 
2.17.2


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2019-02-05 20:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-05 20:22 [PATCH v2] mac80211: mesh: do mesh rhashtable walks with BHs disabled Johannes Berg

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.