Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp3147986pxb; Tue, 20 Apr 2021 01:26:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5WgMx0/xCX5RWSR67qhnjkCwI758FjgNYKnNal5oBZu3AFZYwy6Zm964jLaEFQCWJ/k73 X-Received: by 2002:a17:907:7b98:: with SMTP id ne24mr23349959ejc.304.1618907170573; Tue, 20 Apr 2021 01:26:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618907170; cv=none; d=google.com; s=arc-20160816; b=WBLGa7nfV61zX7VUCO+wl0jUeYFeJxi2m24UtlyjoDPqXXRJLuLyw8fUMRVbblADtu 2Hqxlt0nbMkirx0TIRebEH43RVhq+6ohHHEanlVFvjh1FvzOnp3cVZENsq+Y7oV7LQVx KcxUhjlF8aBtkLjAp/7J9OfNeh0R6Za1CDufF7V1ElPh/3ToZ0AUAgbrLjQdrw6tRiK1 sG5eYpyvkCDagLrzzMuz5mhc7EbdCuo6tIhufebPtSkA0p6fl+J8R5bRSmwYsLnQ372n dwUGRzU3DZa1n1qt/q5crhNWXE+WczLAy4ieOwzX3uezLpL9uHQjYoPnTP3ZFX3XTWbt 7O6A== 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 :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=mXw6bann/NGFHSn5gQhgTByhQpnwwUtzUaGOPxVcryQ=; b=QGlxJZf/pjSpt2wsmtT+9dujTl4QCZMx6p/GTm0h2CPrTH14sc9KonPyBdL+DReXgD fuWQsa6aioZX2DGW8nbkeWl289btFQyqHGQ6eP1aM70pcWMFdq83XQ0E4VqG1oDEHwe3 q61vyNPEjVn8r/oo+dgioo/a/lDAALvhK9LzQnoCP7rgUSQAhoAhEy1pi7NCoO+qTNd3 5v8CBh2vyFSRZn0edeTpGkzE6xlTNBdxSiTUvRUA3ziN9FzzbqAk5kKuG1pPJ47L58PJ sp6C2LrOcPjXgUBHDxS6lmK5h9qJwLFCPLZlb6hZ/FyElSL8bDgXfdCFZTDqD5LlqMB5 3VaA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gn17si14710881ejc.324.2021.04.20.01.25.45; Tue, 20 Apr 2021 01:26:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229593AbhDTI0F (ORCPT + 99 others); Tue, 20 Apr 2021 04:26:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229543AbhDTI0E (ORCPT ); Tue, 20 Apr 2021 04:26:04 -0400 Received: from sipsolutions.net (s3.sipsolutions.net [IPv6:2a01:4f8:191:4433::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18E30C06174A for ; Tue, 20 Apr 2021 01:25:33 -0700 (PDT) Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.94) (envelope-from ) id 1lYlhK-00EBzy-L8; Tue, 20 Apr 2021 10:25:30 +0200 Message-ID: <8f68ffae49cebca084658b810add0e6020002838.camel@sipsolutions.net> Subject: Re: [PATCH v9 2/4] mac80211: add multiple bssid support to interface handling From: Johannes Berg To: Aloka Dixit Cc: linux-wireless@vger.kernel.org, John Crispin Date: Tue, 20 Apr 2021 10:25:29 +0200 In-Reply-To: <865a59c2dd3a07c4ee88716f51759e88@codeaurora.org> References: <20210310182604.8858-1-alokad@codeaurora.org> <20210310182604.8858-3-alokad@codeaurora.org> (sfid-20210310_192729_241525_2DF37B20) <7f6f0a8c151746e8bb44ad50daf75259a0fac829.camel@sipsolutions.net> <494efc64a803693324dee5b7a03cfda0@codeaurora.org> <9ce462d7c0dc707259d8bb50ec27a189ec89ef61.camel@sipsolutions.net> <865a59c2dd3a07c4ee88716f51759e88@codeaurora.org> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.38.4 (3.38.4-1.fc33) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-malware-bazaar: not-scanned Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Hi Aloka, > > Is rcu_read_lock is not allowed around dev_close() because it might > block or *ANY* lock? Well, I guess it's more nuanced than that. rcu_read_lock() is not allowed because it enters an atomic context. Similarly not allowed would be spinlocks, or local_bh_disable, or any similar thing that makes the context atomic. From a locking perspective, normal mutexes *would* be allowed. However, you'd have to be extremely careful to not allow recursion, since dev_close() will call back into cfg80211/mac80211. > Because both functions with new dev_close() themselves are called with > locks held, > (1) ieee80211_do_stop() happens inside > wiphy_lock(sdata->local->hw.wiphy) This is probably already problematic. > (2) ieee80211_del_iface() happens inside mutex_lock(&rdev->wiphy.mtx). As you discovered, that's the same lock. > Should these be unlocked temporarily too before calling dev_close()? I don't think temporarily dropping locks is ever a good idea, it makes it really hard to reason about the code. But we already do this for AP-VLAN interfaces, so not sure why this is so different? > > Also, in cfg.c, list_for_each_entry(sdata, &local->interfaces, list) is > called with two different murexes: (1) local->iflist_mtx > (2) local->mtx > > Which is the correct one for this purpose among above two and > rcu_read_lock()? > Once that decided, would following be sufficient - >      lock() >      list_for_each_entry(sdata, &local->interfaces, list) { >          get_child_pointer >          unlock() >          dev_close() What guarantees you don't lose the device after the unlock()? I think you'd risk list corruption here this way... Look at the other instance of dev_close() here - as long as you can guarantee there won't be recursion (and you do, because non-transmitting interfaces don't have other non-transmitting below them, though they may actually have AP-VLANs!), we should be fine just doing it like that code? johannes