Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp5677936pxb; Mon, 14 Feb 2022 05:09:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJwR3Q72hxPVE8uI94ZncyJEAMbbyoUBfQm4pSbdTHNWeIyOfuWh1QWCQL7tMjuyS9llAKWr X-Received: by 2002:a17:902:ce92:: with SMTP id f18mr12456579plg.25.1644844171314; Mon, 14 Feb 2022 05:09:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644844171; cv=none; d=google.com; s=arc-20160816; b=PFiyCRq0YtXGKV4sDW6zigPDg6F1DI/lUQPsvAxMrVEHyAWl2caR4jQo2N+d4/0huW y0YV4BxJMPtGmDnDW1P779+1JA4RjA1DZYSmZNFvx1NXlPnCNVkleVXvRyK9Ll1QGg2F cUiPfadV8ZaCgYycg4HD4q8hyY6LV/KcfTFx9yLo1C0ePKGz+7d8mZA4mheZk395NRmG cJkkvZkGCYXqIK7iqrPhU81MPLjv+JrIa1OLh2k5UYs/waZnLX7G/nQ2AkWYViCb3Cof ThPL9Mz5cL/lBi2ol3IdbJgETUfYz9oIXcoP2LYk6eaMy+AUm/E0PzTiwSz7cM8X7Al2 foAQ== 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:dkim-signature; bh=H3hFWxFo1JZg0rgEYljGhwgXqDGAAibdkEhAbcu6u2I=; b=1Kn7RafzvpQkgPHW7vDV+RT2qJGY8vtMFBN8Flpp/Apa5c3OLY4Is2ePAr7rd1FBY0 6BAB1VNYOaaRHW7IaJvaWoyuuUEqMtS+g4AZ2EiSLOBogfvVyO5qzYmfIdiIqr+qdDN/ c3N9+oRV6udNFGxxWS7DVKNcka+l+amcFqX6sCHumkJwzrGoLBdZ0otznZfOyPAkpbkn 1vqcYyhWMRTOHtrVAHb2kJQS32kSMo/c0JnNtrXskWFnyUYcWS3xRMVQk/Ss4wcTmnsk gnLOPBtkzf2p6U34OjlYRLcae9SYaw1hcPKwYbnZdioxrcpwB5lU+K1sGCEQLn9PelPw SLrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=O420U03d; 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; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c7si1624137pgu.757.2022.02.14.05.09.14; Mon, 14 Feb 2022 05:09:31 -0800 (PST) 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; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=O420U03d; 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; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242729AbiBNJRt (ORCPT + 71 others); Mon, 14 Feb 2022 04:17:49 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:35380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235592AbiBNJRt (ORCPT ); Mon, 14 Feb 2022 04:17:49 -0500 Received: from sipsolutions.net (s3.sipsolutions.net [IPv6:2a01:4f8:191:4433::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00A9A606E8 for ; Mon, 14 Feb 2022 01:17:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version: Content-Type:References:In-Reply-To:Date:Cc:To:From:Subject:Message-ID:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=H3hFWxFo1JZg0rgEYljGhwgXqDGAAibdkEhAbcu6u2I=; t=1644830262; x=1646039862; b=O420U03dmXErH124OWKkE68A1xIVBet9se3oca3HKwBf8Gu VXJFHX6fkof5VtLH9TaLvIpElBJ6pABsIvnJuT5u2F3H052t0COGAdWu5N0XhZs43KXzeOY1i6fGz z9WIe72oEDgmSA3AP+R902dDRPqEgEysLiOv74G/VeblVe2YxcRJ7SwIDSKKVZD46WKzh6moyVAYX 3qb0dO9GYZxsnlietilh8OFDCDc26fqfoFfc3f+xK1ryyavPGChTWlqLhltGQmX1myVCgxASxRo9O ozyuoSa/UNZfjJ79i0bTbiAWNOIWZ4WnAAaf8Lr0VhbhubmSHlBzNsdE9dPLH+FQ==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.95) (envelope-from ) id 1nJXUJ-000tvV-EW; Mon, 14 Feb 2022 10:17:39 +0100 Message-ID: <689fcef44a12f33281dccfe35e56859bccd1c058.camel@sipsolutions.net> Subject: Re: locking in wiphy_apply_custom_regulatory() From: Johannes Berg To: Arend van Spriel Cc: linux-wireless Date: Mon, 14 Feb 2022 10:17:38 +0100 In-Reply-To: <8c9879f5-fcfc-69e5-5803-e8b5b1fabfd0@broadcom.com> References: <6562d8c3-27f6-490a-7732-6c300eb3aa64@broadcom.com> <8c9879f5-fcfc-69e5-5803-e8b5b1fabfd0@broadcom.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.3 (3.42.3-1.fc35) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-malware-bazaar: not-scanned X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 On Mon, 2022-02-14 at 09:45 +0100, Arend van Spriel wrote: > > Correct. Just not sure I understand why is has to be RTNL lock. Well, does it? Now I forgot again from when I looked ;-) Surely for nl80211_get_reg_do() for example it has to be, at least today, though that is already protecting the regdom with RCU in the non- wiphy case, so doesn't really need to use RTNL. Similarly, nl80211_get_reg_dump() could use RCU. So that's easy, but all the interaction e.g. with brcms_reg_notifier() calling freq_reg_info() which uses it too, but then is called from wiphy_update_regulatory() from e.g. update_all_wiphy_regulatory() only with RTNL makes it all complicated ... > So would wiphy mutex be sufficient. I guess my question is what is > protected by these lock in wiphy_apply_custom_regulatory() and is it > really necessary to have both. See above. Honestly, I wouldn't mind if wiphy mutex (or RCU) _was_ sufficient. But we're not there, and the regulatory code is sufficiently complex and called sufficiently infrequently that I just haven't bothered trying to reduce its reliance on the RTNL. > Just some experimental coding where I ended up calling > wiphy_apply_custom_regulatory() upon IFF_UP and hit deadlock because > RTNL was already taken. Anyway, that code already ended up in the > garbage bin, but wanted to ask anyway. Learning by asking (stupid) > questions ;-) > Given the length and depth I had to go to to answer it, that really couldn't be a stupid question :) johannes