Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp5047530rwb; Wed, 21 Sep 2022 02:22:04 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4E7EhqtilTAqQX/KHC/xgu9sn+jdq0vcPyuRpBR5Klcrjn1c+NPYfmkfLiOdj4fyIQg/lZ X-Received: by 2002:a17:906:cc17:b0:781:d78b:e2d3 with SMTP id ml23-20020a170906cc1700b00781d78be2d3mr4875410ejb.83.1663752123880; Wed, 21 Sep 2022 02:22:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663752123; cv=none; d=google.com; s=arc-20160816; b=Led2dzOrrpvT61FOvw5ta6W28ZLfWm/LeaKBwQJuppCmxhl1jZtF/4as+rTb8oioW1 zcJWcxxqDBbaDuArDByvneLoJwk3yaInFxsOWG8Kak6mD6xB2QNi+p+e45wfB9STLkYv 5VmvMzFeem3IfKo+f/CKo2fnF0imO/2MnLSru9AbWLXUT+BzhPUS+yjQQ6RF2nsCsesq Uy0ati7MQZbBkeMtwyxgHIjJLPi5PzXOYtAB6403YPqTvEpyu32V36Dr1Ho1djL3IJ12 5fMyuLb7y73TJSbMDOgQ/03ZvBa9kUdApvtCUlySCKtgGhQxGNVun3xZDVTj0Tdbl7So NOIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=xL7UjVRzdGE551ag4o/32EhjZ1jW9v9LED2M2ZSL5J0=; b=cHlWrPSH7SRaqy+oMfSd6eAqNhSK8cNW79KQL7YQBL+XIrpwQASGQK8U8ZKzs23+9u ncxOay8cE4RBtpMPuCNGaCqv5vq20dUXgTVQw2yovawi3Gbx4eLXdfht+vYWwbFwJEG0 SJiSluBihZpEUdGtEjxdZrCtMAcgVd3n8tQjnmf70Um2oUyYoD83dV7ThgOlRcrNjKCD rxT2AAEPpG2R0K1DSoPgtrQPf0V7fj8Lp2msdAntQ4Qw3s0AgAdqQVoRXcXNV6BIKN94 CXNqfDzwMIvOQ0r44CNnbo+ieWLQG3+02S6CuG7w2JPSl0H5A9ndEgvhQiqDHGQgO4zc w0lw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d18-20020a170906041200b007707ab4be28si1608990eja.972.2022.09.21.02.21.46; Wed, 21 Sep 2022 02:22:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231607AbiIUJU0 (ORCPT + 63 others); Wed, 21 Sep 2022 05:20:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229733AbiIUJUA (ORCPT ); Wed, 21 Sep 2022 05:20:00 -0400 Received: from out29-196.mail.aliyun.com (out29-196.mail.aliyun.com [115.124.29.196]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BD1B9080E; Wed, 21 Sep 2022 02:19:19 -0700 (PDT) X-Alimail-AntiSpam: AC=CONTINUE;BC=0.190038|-1;BR=01201311R781S98rulernew998_84748_2000303;CH=blue;DM=|CONTINUE|false|;DS=CONTINUE|ham_system_inform|0.0916624-0.0191534-0.889184;FP=0|0|0|0|0|-1|-1|-1;HT=ay29a033018047212;MF=arda@allwinnertech.com;NM=1;PH=DS;RN=9;RT=9;SR=0;TI=SMTPD_---.PKrbnBk_1663751956; Received: from SunxiBot.allwinnertech.com(mailfrom:arda@allwinnertech.com fp:SMTPD_---.PKrbnBk_1663751956) by smtp.aliyun-inc.com; Wed, 21 Sep 2022 17:19:17 +0800 From: Aran Dalton To: johannes@sipsolutions.net, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: johannes.berg@intel.com, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] cfg80211: fix dead lock for nl80211_new_interface() Date: Wed, 21 Sep 2022 17:19:12 +0800 Message-Id: <20220921091913.110749-1-arda@allwinnertech.com> X-Mailer: git-send-email 2.29.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Both nl80211_new_interface and cfg80211_netdev_notifier_call hold the same wiphy_lock, then cause deadlock. The main call stack as bellow: nl80211_new_interface() takes wiphy_lock -> _nl80211_new_interface: -> rdev_add_virtual_intf -> rdev->ops->add_virtual_intf -> register_netdevice -> call_netdevice_notifiers(NETDEV_REGISTER, dev); -> call_netdevice_notifiers_extack -> call_netdevice_notifiers_info -> raw_notifier_call_chain -> cfg80211_netdev_notifier_call -> wiphy_lock(&rdev->wiphy), cfg80211_register_wdev Fixes: ea6b2098dd02 ("cfg80211: fix locking in netlink owner interface destruction") Signed-off-by: Aran Dalton --- net/wireless/nl80211.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 2705e3ee8fc4..bdacddc3ffa3 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -4260,9 +4260,7 @@ static int nl80211_new_interface(struct sk_buff *skb, struct genl_info *info) /* to avoid failing a new interface creation due to pending removal */ cfg80211_destroy_ifaces(rdev); - wiphy_lock(&rdev->wiphy); ret = _nl80211_new_interface(skb, info); - wiphy_unlock(&rdev->wiphy); return ret; } -- 2.29.0