Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp657312pxv; Thu, 15 Jul 2021 12:40:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwO2vA2N7BLd1t0v+1ArT9nmj5WkHX4h62t6rr92iWjuFdFMvBsQ+yuWvSAjXx4oOrx0Ub X-Received: by 2002:aa7:ca1a:: with SMTP id y26mr9303033eds.231.1626378009570; Thu, 15 Jul 2021 12:40:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626378009; cv=none; d=google.com; s=arc-20160816; b=ZOyRc7zrQQc7XG+P4ZcmaPHKgRyFARMdPLD7YEI2i7QOTXefy1+ZjSDSr6VtikSczV 5+RSg25vuRtYrq7zXvYeHSiLAPrI0F35athsd5BErPHg0hAmx93qoaxQfmJdCccvzOYk EOgeLfDJlOCoU4hcN94kSUXMRc1gnRRONJ2nAK1Q+kmwa5eCpPoXcJRHcV0O6r8I0iGe 7DMYXrzCbozltCgMJkCrfpHfgj7bjq5O0N28QZdYm+0mQcrKoPz2DZiZ6YbsFJUfk3N6 rbqPysa+695MCNTzBE9Ma2w8WbMelGOBMe50ut/K/HUH6fcXhVVoOt5bDG9QHslTpetJ XX9w== 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=NCrMy7z/myIPvg2vSVvd1NyFHlxBlKH/cT+PcdBCw4g=; b=gx8jFUya/eaEcrjF8jljZ5gaDbDVXkdLk90fmehNtZT5lAM087t4O4rZd/qtmannse he2SvUNHXxv9PwO7CfeHZi2WvXJC2LGsd5JAP7c/YPVJfH+Pp0sXQIwfqeJAa9OIwAyJ ma2znvUH3nkMgLeSR2XSHCipJ8ujtLerrMepWTeEtYE2nEmIzAPl+GbMd9+Hg3B7taFY YszfT/2tPcd4YEe/2vXfMv2Y6AmxG2GKW5Wd6VIN6x26lXd26gSthbPHpTCVIBXaMZb+ JvZxYoY3ApnlW6Nq328rXlcu6vmc59Rhf0+OiCyJChqiFwJSI/dFsTQpgreMRTx/lzbb URAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=D0GIyO4N; 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 v16si4136283edx.585.2021.07.15.12.39.46; Thu, 15 Jul 2021 12:40:09 -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=D0GIyO4N; 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 S245347AbhGOThQ (ORCPT + 99 others); Thu, 15 Jul 2021 15:37:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:51090 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242142AbhGOTMu (ORCPT ); Thu, 15 Jul 2021 15:12:50 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 283CC613C0; Thu, 15 Jul 2021 19:09:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626376159; bh=eGCsxFpG369ra2/yp5FBcSX3MxKYhKaMSefN2aQyDZU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D0GIyO4Nqw9qugWT9Gnf1Xtvva+UI2ybXR3zcCSkpk9J3pbPSu2X9XsStk/7PArK2 Ky/1/M821zKiuO0hB3ol2Fbb//7aecDiam5e7LJXSU+DAnl98U4Rhi5nKnFSIhhPFe BNx8Xo5PuSlnvmy9h4bN7hmduf4dALPfA0TO9Mtc= 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.13 151/266] mac80211: Properly WARN on HW scan before restart Date: Thu, 15 Jul 2021 20:38:26 +0200 Message-Id: <20210715182639.956601431@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182613.933608881@linuxfoundation.org> References: <20210715182613.933608881@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 f33a3acd7f96..2481bfdfafd0 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