From patchwork Tue Feb 5 14:37:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 10797493 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 BC71113B4 for ; Tue, 5 Feb 2019 14:37:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC87A2C11A for ; Tue, 5 Feb 2019 14:37:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9EBCA2C32F; Tue, 5 Feb 2019 14:37:18 +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 EB86C2C11A for ; Tue, 5 Feb 2019 14:37:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729230AbfBEOhP (ORCPT ); Tue, 5 Feb 2019 09:37:15 -0500 Received: from s3.sipsolutions.net ([144.76.43.62]:36182 "EHLO sipsolutions.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726533AbfBEOhP (ORCPT ); Tue, 5 Feb 2019 09:37:15 -0500 Received: by sipsolutions.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92-RC4) (envelope-from ) id 1gr1qZ-00078Q-DU; Tue, 05 Feb 2019 15:37:11 +0100 From: Johannes Berg To: linux-wireless@vger.kernel.org, netdev@vger.kernel.org Cc: Jouni Malinen , Thomas Graf , Herbert Xu , Johannes Berg Subject: [PATCH] rhashtable: use irq-safe spinlock in rhashtable_rehash_table() Date: Tue, 5 Feb 2019 15:37:06 +0100 Message-Id: <20190205143706.28371-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 When an rhashtabl walk is done from irq/bh context, we rightfully get a lockdep complaint saying that we could get a (soft-)IRQ in the middle of a rehash. This happened e.g. in mac80211 as it does a walk in soft-irq context. Fix this by using irq-safe locking here. We don't need _irqsave() as we know this will be called only in process context from the workqueue. We could get away with _bh() but that seems a bit less generic, though I'm not sure anyone would want to do a walk from a real IRQ handler. Reported-by: Jouni Malinen Signed-off-by: Johannes Berg --- lib/rhashtable.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/rhashtable.c b/lib/rhashtable.c index 852ffa5160f1..ad3c1da15475 100644 --- a/lib/rhashtable.c +++ b/lib/rhashtable.c @@ -327,10 +327,10 @@ static int rhashtable_rehash_table(struct rhashtable *ht) /* Publish the new table pointer. */ rcu_assign_pointer(ht->tbl, new_tbl); - spin_lock(&ht->lock); + spin_lock_irq(&ht->lock); list_for_each_entry(walker, &old_tbl->walkers, list) walker->tbl = NULL; - spin_unlock(&ht->lock); + spin_unlock_irq(&ht->lock); /* Wait for readers. All new readers will see the new * table, and thus no references to the old table will