Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp710862pxv; Thu, 15 Jul 2021 14:08:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxyp7rCTP9xVbKoDKXRkPcFP6vVAWeLyidR63xMesqdSWLijM1MVHP9jHgvtR6HGNbP95fr X-Received: by 2002:a50:fb95:: with SMTP id e21mr9848250edq.65.1626383308934; Thu, 15 Jul 2021 14:08:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626383308; cv=none; d=google.com; s=arc-20160816; b=wz6KmQcm7QEfwBlrd0MPjby0HGybJKfVQLTfK6crNIi8PY9co78fr9ToWnvpCwLqNO ESFXV96WMqUtGigbwY+HQ3vs1qDNlzz+Aj1TsMQ+lsCTsi8aFR3nFSr7Ma0qwdkA5t/8 sl5x8dKLaaH2uqYeRpsCQgjGTCUhS4Tz677fVpFago+VxGvbrDac1FoqfNMvOTx1BDld 9zu/f7NqS6uCRndjkrNvGKSyy5Z6IdhiMMzCWZ2B7vad3eisgOt/pA+XRN61LiJt5Hvr MKRe0mDPlg7A6OwxwF+39oh7HEv0u/BipgtSsv1q+gSNABsZefHwjygJeTH++K7Nq7tm Osbw== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=yffpBEGIvQSKsy3utx0c+YNw7TXTYNjpJGjPyWqI19c=; b=cavatEh1Vsv179yNmzmvRlR+Usy2YiFVizwUFiNPYV65ED4TnNg8aJIE6G/WvqUKs4 FhT+KUfsfNvq64mdCdX2nNS56sO7F1J2oDMRo0j2u88VDJziLucSs2iqSNKfGRocJ3zL N1AH1UWFQphJbL77UClcPmIrWeOULd3ndD8SZaOxdIh0V3ebXkLmcao6YtDdIZGPk5HX v1BJkM9v1Nor1pgT7ehuBsUW6nd+4tvGPWz4fTwrZZrjZoMqPGXDBuf1yZWdibh0mz2N uBDqVO8vb036ul5LzkJ0jK+KK96MMB6sEg541mxBqHuTPtCtPYp+wS1AqsGfmaIbI3Ix lOiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yKcVinas; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b2si8306920ejc.314.2021.07.15.14.08.05; Thu, 15 Jul 2021 14:08:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yKcVinas; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243625AbhGOTSK (ORCPT + 99 others); Thu, 15 Jul 2021 15:18:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:38428 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242930AbhGOTC1 (ORCPT ); Thu, 15 Jul 2021 15:02:27 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C319E613D6; Thu, 15 Jul 2021 18:58:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626375534; bh=i9LbO88BQlRz9UewtnHD4ToRZXkZ1jIba8GKpBuY0pk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yKcVinasdrnJRpf43vq0Nf7QjdmNI1sMZLbovtVeRwxFwy327MKUSdJc6F2PHkycK FzykDv6/nI/vzL/C3un5S6p+Mfu6gV2B95NmxQWe2hArMqNOt+RPoinn6QJu0a000s 6MAkdLoOeM7k3GUEfeGa+v1h6Qzgym5Kxlr+C19o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ilan Peer , Luca Coelho , Johannes Berg , Sasha Levin Subject: [PATCH 5.12 129/242] mac80211: Properly WARN on HW scan before restart Date: Thu, 15 Jul 2021 20:38:11 +0200 Message-Id: <20210715182615.746927819@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182551.731989182@linuxfoundation.org> References: <20210715182551.731989182@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ilan Peer [ Upstream commit 45daaa1318410794de956fb8e9d06aed2dbb23d0 ] 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 Link: https://lore.kernel.org/r/iwlwifi.20210618133832.8238ab3e19ab.I2693c581c70251472b4f9089e37e06fb2c18268f@changeid Signed-off-by: Johannes Berg Signed-off-by: Sasha Levin --- 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 9dd741b68f26..937a024a13e2 100644 --- a/net/mac80211/main.c +++ b/net/mac80211/main.c @@ -257,14 +257,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.30.2