Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1361427pxj; Fri, 18 Jun 2021 05:38:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwnjTl/iucUbR2bq4VK4i3n5PXmyQ7zJhpDu5UHBmWC91wAll4fOXVyOzgmbmYhnr6HgdtD X-Received: by 2002:a05:6402:520c:: with SMTP id s12mr4707397edd.304.1624019926943; Fri, 18 Jun 2021 05:38:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624019926; cv=none; d=google.com; s=arc-20160816; b=dKTt936hv3CG17XJMjQ+BZdQuiRvnCmYeEgW0CJogmgnJvEH/6Mng/e7gWHlfW7pU0 xj70AcPwpefD6I12d8RBnVyLIpYZC6HjkjawRoYvwbm4N46zQ2cf4oUjTwrJp2dYoW0Q n+Ctoz1ts2kp3Ae0Fo+QZZnIoBvOFqLSRUCJyrvfcqr+VEBmD96+SU1U5PbjXcuo5Zen 17CI4VKlsS8FhOBlsREw4MlxRXdIHxi2bu7z9VBHhK0wwyzaox9OUTHAvd4gFSMEb2F8 lStzLUgD/6BZHbBk12JZvrjk7YyA9j0PwupUaoH9Dd84LONIbd6HRavAUjbEv+s9m9EG FInA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:cc:to:from; bh=nwNNwwyEKgZr9ocErrPoll/xg5+mkAUsQ+h4W5EEGOw=; b=pLsqGTslts29/JJ7MmNPYK7SFf9uWHGnWmnl1AioxRMyv+iPSnLpbbfmlYhkVBrfXN +diqeefD4XiQ2x86Tz5f01nuU+VvcJlrHdH8QdUOtH8g+llbCp2kh0R8RGFBLMfp84EJ cLEUFv/rl3XYkJElDNjubnGV1Nw0WyshwGUy42QELSuMuJb8IjKJHx6hFSDF/6m/y/vU /jPYHOoeTHwOaBFvcNh4hbO9KhdVkWS6DUC75/ZyJAgxps0qnrLG/Txv9e1CRVHrq/Kh C9XWTVt7mMrTr5xsQs98Z7NTGVy8rIOKsArTqr0t4sftP19t2ubOuyaQly2bGhIvJWMd LKWQ== 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 g2si4246191edb.593.2021.06.18.05.38.24; Fri, 18 Jun 2021 05:38:46 -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 S231838AbhFRLIp (ORCPT + 99 others); Fri, 18 Jun 2021 07:08:45 -0400 Received: from paleale.coelho.fi ([176.9.41.70]:48280 "EHLO farmhouse.coelho.fi" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231810AbhFRLIp (ORCPT ); Fri, 18 Jun 2021 07:08:45 -0400 Received: from 91-156-6-193.elisa-laajakaista.fi ([91.156.6.193] helo=kveik.lan) by farmhouse.coelho.fi with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94) (envelope-from ) id 1luBww-001YXx-Kd; Fri, 18 Jun 2021 13:42:12 +0300 From: Luca Coelho To: johannes@sipsolutions.net Cc: luca@coelho.fi, linux-wireless@vger.kernel.org Date: Fri, 18 Jun 2021 13:41:37 +0300 Message-Id: X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210618104156.747775-1-luca@coelho.fi> References: <20210618104156.747775-1-luca@coelho.fi> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on farmhouse.coelho.fi X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, TVD_RCVD_IP autolearn=ham autolearn_force=no version=3.4.5-pre1 Subject: [PATCH 12/31] mac80211: Properly WARN on HW scan before restart Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Ilan Peer The following race was possible: 1. The device driver requests HW restart. 2. A scan is requested from user space and is propagated to the driver. During this flow HW_SCANNING flag is set. 3. The thread that handles the HW restart is scheduled, and before starting the actual reconfiguration it checks that HW_SCANNING is not set. The flow does so without acquiring any lock, and thus the WARN fires. Fix this by checking that HW_SCANNING is on only after RTNL is acquired, i.e., user space scan request handling is no longer in transit. Signed-off-by: Ilan Peer Signed-off-by: Luca Coelho --- net/mac80211/main.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/net/mac80211/main.c b/net/mac80211/main.c index 62145e5f9628..da3e0ca6aa31 100644 --- a/net/mac80211/main.c +++ b/net/mac80211/main.c @@ -256,14 +256,13 @@ static void ieee80211_restart_work(struct work_struct *work) /* wait for scan work complete */ flush_workqueue(local->workqueue); flush_work(&local->sched_scan_stopped_work); + flush_work(&local->radar_detected_work); + + rtnl_lock(); WARN(test_bit(SCAN_HW_SCANNING, &local->scanning), "%s called with hardware scan in progress\n", __func__); - flush_work(&local->radar_detected_work); - /* we might do interface manipulations, so need both */ - rtnl_lock(); - wiphy_lock(local->hw.wiphy); list_for_each_entry(sdata, &local->interfaces, list) { /* * XXX: there may be more work for other vif types and even -- 2.32.0