From patchwork Tue Feb 5 20:22:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 10798357 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 406DD13B4 for ; Tue, 5 Feb 2019 20:22:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F60C2C349 for ; Tue, 5 Feb 2019 20:22:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 23E3E2C4B9; Tue, 5 Feb 2019 20:22:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD2A22C349 for ; Tue, 5 Feb 2019 20:22:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727870AbfBEUWz (ORCPT ); Tue, 5 Feb 2019 15:22:55 -0500 Received: from s3.sipsolutions.net ([144.76.43.62]:41016 "EHLO sipsolutions.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726726AbfBEUWy (ORCPT ); Tue, 5 Feb 2019 15:22:54 -0500 Received: by sipsolutions.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92-RC4) (envelope-from ) id 1gr7F6-0006ta-CB; Tue, 05 Feb 2019 21:22:52 +0100 From: Johannes Berg To: linux-wireless@vger.kernel.org Cc: Johannes Berg Subject: [PATCH v2] mac80211: mesh: do mesh rhashtable walks with BHs disabled Date: Tue, 5 Feb 2019 21:22:49 +0100 Message-Id: <20190205202249.10439-1-johannes@sipsolutions.net> X-Mailer: git-send-email 2.17.2 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Johannes Berg 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 Signed-off-by: Johannes Berg --- 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)