mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Aran Dalton <arda@allwinnertech.com>
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 2/2] cfg80211: fix dead lock for nl80211_del_interface()
Date: Wed, 21 Sep 2022 17:19:13 +0800	[thread overview]
Message-ID: <20220921091913.110749-2-arda@allwinnertech.com> (raw)
In-Reply-To: <20220921091913.110749-1-arda@allwinnertech.com>

Both nl80211_del_interface and cfg80211_netdev_notifier_call hold the
same wiphy_lock, then cause deadlock.

The main call stack as bellow:

nl80211_del_interface() takes wiphy_lock
 -> cfg80211_remove_virtual_intf
  -> rdev_del_virtual_intf
   -> rdev->ops->del_virtual_intf
    -> cfg80211_unregister_netdevice
     -> cfg80211_unregister_wdev
      -> _cfg80211_unregister_wdev
       -> unregister_netdevice
        -> unregister_netdevice_queue
         -> unregister_netdevice_many
          -> call_netdevice_notifiers(NETDEV_UNREGISTER, dev);
           -> call_netdevice_notifiers_extack
            -> call_netdevice_notifiers_info
             -> raw_notifier_call_chain
              -> cfg80211_netdev_notifier_call
               -> wiphy_lock(&rdev->wiphy), _cfg80211_unregister_wdev

Fixes: a05829a7222e ("cfg80211: avoid holding the RTNL when calling the driver")
Signed-off-by: Aran Dalton <arda@allwinnertech.com>
---
 net/wireless/nl80211.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index bdacddc3ffa3..664bf977b7bc 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -4269,6 +4269,7 @@ static int nl80211_del_interface(struct sk_buff *skb, struct genl_info *info)
 {
 	struct cfg80211_registered_device *rdev = info->user_ptr[0];
 	struct wireless_dev *wdev = info->user_ptr[1];
+	int ret;
 
 	if (!rdev->ops->del_virtual_intf)
 		return -EOPNOTSUPP;
@@ -4296,9 +4297,11 @@ static int nl80211_del_interface(struct sk_buff *skb, struct genl_info *info)
 	else
 		dev_close(wdev->netdev);
 
+	ret = cfg80211_remove_virtual_intf(rdev, wdev);
+
 	mutex_lock(&rdev->wiphy.mtx);
 
-	return cfg80211_remove_virtual_intf(rdev, wdev);
+	return ret;
 }
 
 static int nl80211_set_noack_map(struct sk_buff *skb, struct genl_info *info)
-- 
2.29.0


  reply	other threads:[~2022-09-21  9:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-21  9:19 [PATCH 1/2] cfg80211: fix dead lock for nl80211_new_interface() Aran Dalton
2022-09-21  9:19 ` Aran Dalton [this message]
2022-09-21 15:03 ` Jeff Johnson
2022-09-21 16:36 ` Johannes Berg

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=20220921091913.110749-2-arda@allwinnertech.com \
    --to=arda@allwinnertech.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=johannes.berg@intel.com \
    --cc=johannes@sipsolutions.net \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®