Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp90362lqh; Mon, 6 May 2024 12:12:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX8ep7H994fpw04q21kVxhwtUWg77avMAY+U3H7zuqy6JKZ+f6wKySwBEIg4+ZAU8vBNDrKEebgQ+1w6PKLmQmHrUYsKCbi9ISWtqRfgA== X-Google-Smtp-Source: AGHT+IEU+JzGHC3I7RbdCdkh6KIzAjsYvKy7WLwNyOEXEu9/5DGYZXB7sIrqcH6y/A/LsIDUGL6m X-Received: by 2002:ac8:5792:0:b0:43a:b55d:64e2 with SMTP id v18-20020ac85792000000b0043ab55d64e2mr11067702qta.45.1715022729790; Mon, 06 May 2024 12:12:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715022729; cv=pass; d=google.com; s=arc-20160816; b=zXetjgPpUE541AwimexW7Hp1dP4d6IQk1ZD2MdjhR/Ap8LNbooPDFqSujmunEFCWIs RhydDw7dZaak2oujU2kO3+HrJnl8y3n7xv3AyWUHZO/oDj7udpoe/Sl4b04KQ8B81sht St4DTOmCbVBT2qiAc1+MM4tqO58fbF3Ivl9Vx9YDTMBskGNX9UgJEmOEt68au10ataoW EigINkQHFVSRtb/7AKkDjSmzyEVKR86cLGRzj8qsCE3ZGkr28FhhiYVOxI7N9tLJUHcg QceaW0tYH3qx4hctDZ/OXDyuCiqbdslAU7bLJcDF4NGVhlAv86P7FXU2jMEZTWSQfGGN 8fBw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=QtfIGuDdDrojIF9YOp5yzZ31nhq53McENukWYemk+30=; fh=0ZKV22Mpi0Z+/zRlCC9GRUAKl0wLMxmYgR1nXO1NAEs=; b=w43NwYEiSwgWI0Ge5uTVcVjmTV0YH9qYkAxMznO7JDOZ5oX/GIHOC904e91gp1UlqQ MT6tKg528YDizK8PEtEVMt5Wju8U5s3nExWGR4k1/mUpeWWgh3ighuA0VHCtuKUFrt1q gwAU3gNGXszt9Cw3tBVqX1D4d3pILLmTgha18v6MhJZCixn6tQY5eJuuF3Z1AYeXHJbg a3gC7rhbUoLnZsKNxx1Uajzygy5KBrwSeEAreI8/92tLSTW27yL2VoCL+BJ2YvR+mPj1 V8XB6pmZPiL3OqzTlrYyWk5I6El8aQiV3eOTbeWjYcK3qMjTe/2/e92AN+2Mol1y6TCN zDjQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=UBoO94JG; arc=pass (i=1 spf=pass spfdomain=sipsolutions.net dkim=pass dkdomain=sipsolutions.net dmarc=pass fromdomain=sipsolutions.net); spf=pass (google.com: domain of linux-wireless+bounces-7238-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-wireless+bounces-7238-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id y16-20020ac85f50000000b0043aff945b2csi10415557qta.402.2024.05.06.12.12.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 12:12:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless+bounces-7238-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=UBoO94JG; arc=pass (i=1 spf=pass spfdomain=sipsolutions.net dkim=pass dkdomain=sipsolutions.net dmarc=pass fromdomain=sipsolutions.net); spf=pass (google.com: domain of linux-wireless+bounces-7238-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-wireless+bounces-7238-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 642021C20EE0 for ; Mon, 6 May 2024 19:12:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 31FB5158D95; Mon, 6 May 2024 19:12:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b="UBoO94JG" X-Original-To: linux-wireless@vger.kernel.org Received: from sipsolutions.net (s3.sipsolutions.net [168.119.38.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 16F3115572C for ; Mon, 6 May 2024 19:12:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=168.119.38.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715022727; cv=none; b=psldQ7VuwEs1yQPjvjviIu4omTKYEtzN1MyWRp1rBET+RgS9mKFWSgd9FrvvpvVZEFgHbR+8lDFmsxMBmE25kJ5m6prFLMCJZmlpQwhBbDoz4GwdyVgqrgNt+hVA3eAik/CiOVYrYgwcB7NPwUBHHNdeOp7UOG1cAp1DREeOG/0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715022727; c=relaxed/simple; bh=L/PkHj+pMsi0K1q6dTJUAkB1uVJ2m2r7wB++8YyEDfk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=ZrxPzUDUHcWTAVnvgxIsUEWB1EvmDmW7CL/eJOBXmn5o7oCng3TkiNg7weH0MVx/UXMpjDqrMcJAOpPyocCbZ979Zt3e3CjZmAxnBRNaBaE6AxcSqsvEOEzEsAD664VWSCCWK/iu4IplwFA1fl/XqeM74z8Wh3u7/Gdfao9IvE8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net; spf=pass smtp.mailfrom=sipsolutions.net; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b=UBoO94JG; arc=none smtp.client-ip=168.119.38.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sipsolutions.net DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version: Message-ID:Date:Subject:Cc:To:From:Content-Type:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-To:Resent-Cc: Resent-Message-ID:In-Reply-To:References; bh=QtfIGuDdDrojIF9YOp5yzZ31nhq53McENukWYemk+30=; t=1715022725; x=1716232325; b=UBoO94JGFMBBP5iPjBOKldCVguQ+5yTXHJtmETUNUSvZ6cwumiypQH0f9qne9jxh7PnAGrMg4pb 5I2z46y47SqUCr1vVaH27M2Cbhdqk3tMStjUI1IKwZkqaLGRCUnNQlVfpYGBV7LR7xxqz24MbtUWF /EDdihYyxVpUb6s8ovG7zeqOBBBhn4jW46C//DHlbnnJkcATlfmJzVi/4lURysj1Lflq+x0LpsTG+ sc+z/vaGFkhMTFopdO6m7j5/wvbC6FuwRE0kpuoDHAQUvA7wTnvVfur4zEF0fm2vlwC1ocz3wPVFc SSL/3Xd07ZOlNXC4/+p9N/4EFK3KPBbNAi5g==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from ) id 1s43ko-000000089rf-0A6p; Mon, 06 May 2024 21:12:02 +0200 From: Johannes Berg To: linux-wireless@vger.kernel.org Cc: Johannes Berg , Miriam Rachel Korenblit Subject: [PATCH] wifi: cfg80211: restrict operation during radar detection Date: Mon, 6 May 2024 21:11:59 +0200 Message-ID: <20240506211158.ae8dca3d0d6c.I7c70a66a5fbdbc63a78fee8a34f31d1995491bc3@changeid> X-Mailer: git-send-email 2.44.0 Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Johannes Berg Just like it's not currently possible to start radar detection while already operating, it shouldn't be possible to start operating while radar detection is running. Fix that. Also, improve the check whether operating (carrier might not be up if e.g. attempting to join IBSS). Reviewed-by: Miriam Rachel Korenblit Signed-off-by: Johannes Berg --- net/wireless/ibss.c | 5 ++++- net/wireless/mesh.c | 5 ++++- net/wireless/nl80211.c | 21 +++++++++++++++------ 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/net/wireless/ibss.c b/net/wireless/ibss.c index 9f02ee5f08be..34e5acff3935 100644 --- a/net/wireless/ibss.c +++ b/net/wireless/ibss.c @@ -3,7 +3,7 @@ * Some IBSS support code for cfg80211. * * Copyright 2009 Johannes Berg - * Copyright (C) 2020-2023 Intel Corporation + * Copyright (C) 2020-2024 Intel Corporation */ #include @@ -94,6 +94,9 @@ int __cfg80211_join_ibss(struct cfg80211_registered_device *rdev, lockdep_assert_held(&rdev->wiphy.mtx); + if (wdev->cac_started) + return -EBUSY; + if (wdev->u.ibss.ssid_len) return -EALREADY; diff --git a/net/wireless/mesh.c b/net/wireless/mesh.c index 83306979fbe2..aaca65b66af4 100644 --- a/net/wireless/mesh.c +++ b/net/wireless/mesh.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 /* * Portions - * Copyright (C) 2022-2023 Intel Corporation + * Copyright (C) 2022-2024 Intel Corporation */ #include #include @@ -127,6 +127,9 @@ int __cfg80211_join_mesh(struct cfg80211_registered_device *rdev, if (!rdev->ops->join_mesh) return -EOPNOTSUPP; + if (wdev->cac_started) + return -EBUSY; + if (!setup->chandef.chan) { /* if no channel explicitly given, use preset channel */ setup->chandef = wdev->u.mesh.preset_chandef; diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 3c0bca4238d3..71cbe5d15994 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -5937,6 +5937,9 @@ static int nl80211_start_ap(struct sk_buff *skb, struct genl_info *info) if (!rdev->ops->start_ap) return -EOPNOTSUPP; + if (wdev->cac_started) + return -EBUSY; + if (wdev->links[link_id].ap.beacon_interval) return -EALREADY; @@ -9929,6 +9932,17 @@ static int nl80211_start_radar_detection(struct sk_buff *skb, flush_delayed_work(&rdev->dfs_update_channels_wk); + switch (wdev->iftype) { + case NL80211_IFTYPE_AP: + case NL80211_IFTYPE_P2P_GO: + case NL80211_IFTYPE_MESH_POINT: + case NL80211_IFTYPE_ADHOC: + break; + default: + /* caution - see cfg80211_beaconing_iface_active() below */ + return -EINVAL; + } + wiphy_lock(wiphy); dfs_region = reg_get_dfs_region(wiphy); @@ -9959,12 +9973,7 @@ static int nl80211_start_radar_detection(struct sk_buff *skb, goto unlock; } - if (netif_carrier_ok(dev)) { - err = -EBUSY; - goto unlock; - } - - if (wdev->cac_started) { + if (cfg80211_beaconing_iface_active(wdev) || wdev->cac_started) { err = -EBUSY; goto unlock; } -- 2.44.0