Skip to content

Commit 2d33ecf

Browse files
committed
wifi: cfg80211: restrict operation during radar detection
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 <[email protected]> Link: https://msgid.link/20240506211158.ae8dca3d0d6c.I7c70a66a5fbdbc63a78fee8a34f31d1995491bc3@changeid Signed-off-by: Johannes Berg <[email protected]>
1 parent ce9e660 commit 2d33ecf

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

net/wireless/ibss.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Some IBSS support code for cfg80211.
44
*
55
* Copyright 2009 Johannes Berg <[email protected]>
6-
* Copyright (C) 2020-2023 Intel Corporation
6+
* Copyright (C) 2020-2024 Intel Corporation
77
*/
88

99
#include <linux/etherdevice.h>
@@ -94,6 +94,9 @@ int __cfg80211_join_ibss(struct cfg80211_registered_device *rdev,
9494

9595
lockdep_assert_held(&rdev->wiphy.mtx);
9696

97+
if (wdev->cac_started)
98+
return -EBUSY;
99+
97100
if (wdev->u.ibss.ssid_len)
98101
return -EALREADY;
99102

net/wireless/mesh.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: GPL-2.0
22
/*
33
* Portions
4-
* Copyright (C) 2022-2023 Intel Corporation
4+
* Copyright (C) 2022-2024 Intel Corporation
55
*/
66
#include <linux/ieee80211.h>
77
#include <linux/export.h>
@@ -127,6 +127,9 @@ int __cfg80211_join_mesh(struct cfg80211_registered_device *rdev,
127127
if (!rdev->ops->join_mesh)
128128
return -EOPNOTSUPP;
129129

130+
if (wdev->cac_started)
131+
return -EBUSY;
132+
130133
if (!setup->chandef.chan) {
131134
/* if no channel explicitly given, use preset channel */
132135
setup->chandef = wdev->u.mesh.preset_chandef;

net/wireless/nl80211.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5964,6 +5964,9 @@ static int nl80211_start_ap(struct sk_buff *skb, struct genl_info *info)
59645964
if (!rdev->ops->start_ap)
59655965
return -EOPNOTSUPP;
59665966

5967+
if (wdev->cac_started)
5968+
return -EBUSY;
5969+
59675970
if (wdev->links[link_id].ap.beacon_interval)
59685971
return -EALREADY;
59695972

@@ -9956,6 +9959,17 @@ static int nl80211_start_radar_detection(struct sk_buff *skb,
99569959

99579960
flush_delayed_work(&rdev->dfs_update_channels_wk);
99589961

9962+
switch (wdev->iftype) {
9963+
case NL80211_IFTYPE_AP:
9964+
case NL80211_IFTYPE_P2P_GO:
9965+
case NL80211_IFTYPE_MESH_POINT:
9966+
case NL80211_IFTYPE_ADHOC:
9967+
break;
9968+
default:
9969+
/* caution - see cfg80211_beaconing_iface_active() below */
9970+
return -EINVAL;
9971+
}
9972+
99599973
wiphy_lock(wiphy);
99609974

99619975
dfs_region = reg_get_dfs_region(wiphy);
@@ -9986,12 +10000,7 @@ static int nl80211_start_radar_detection(struct sk_buff *skb,
998610000
goto unlock;
998710001
}
998810002

9989-
if (netif_carrier_ok(dev)) {
9990-
err = -EBUSY;
9991-
goto unlock;
9992-
}
9993-
9994-
if (wdev->cac_started) {
10003+
if (cfg80211_beaconing_iface_active(wdev) || wdev->cac_started) {
999510004
err = -EBUSY;
999610005
goto unlock;
999710006
}

0 commit comments

Comments
 (0)