Linux wireless drivers development
 help / color / mirror / Atom feed
* [PATCH v2 1/3] wifi: cfg80211: do not support direct add of station to AP_VLAN interfaces
@ 2026-09-10  8:04 Slawomir Stepien
  2026-09-10  8:04 ` [PATCH v2 2/3] wifi: cfg80211: move link_id validation earlier in nl80211_new_station() Slawomir Stepien
  2026-09-10  8:04 ` [PATCH v2 3/3] wifi: cfg80211: check if AP has been started or joined a mesh before adding new station Slawomir Stepien
  0 siblings, 2 replies; 3+ messages in thread
From: Slawomir Stepien @ 2026-09-10  8:04 UTC (permalink / raw)
  To: syzkaller-bugs, johannes, linux-wireless
  Cc: linux-kernel, syzbot, sst, syzbot+9bdc0c5998ab45b05030

Prevent userspace from adding stations directly to AP_VLAN type
interfaces. Userspace should first add the station to the base interface
(AP type) and then can use CMD_SET_STATION to move it to AP_VLAN. The
other way is by using NL80211_ATTR_STA_VLAN.

Without this path, we cannot check if the AP has been started before
adding the station - wdev for AP_VLAN does not store information about
the base AP interface.

Signed-off-by: Slawomir Stepien <sst@poczta.fm>
---
v2:
* Update commit message with NL80211_ATTR_STA_VLAN

v1:
* https://lore.kernel.org/all/20260813090434.2071318-1-sst@poczta.fm/
---
 net/wireless/nl80211.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 899b6374c550..fd784fa3fff8 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -9556,7 +9556,6 @@ static int nl80211_new_station(struct sk_buff *skb, struct genl_info *info)
 
 	switch (wdev->iftype) {
 	case NL80211_IFTYPE_AP:
-	case NL80211_IFTYPE_AP_VLAN:
 	case NL80211_IFTYPE_P2P_GO:
 		/* ignore WME attributes if iface/sta is not capable */
 		if (!(rdev->wiphy.flags & WIPHY_FLAG_AP_UAPSD) ||
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH v2 2/3] wifi: cfg80211: move link_id validation earlier in nl80211_new_station()
  2026-09-10  8:04 [PATCH v2 1/3] wifi: cfg80211: do not support direct add of station to AP_VLAN interfaces Slawomir Stepien
@ 2026-09-10  8:04 ` Slawomir Stepien
  2026-09-10  8:04 ` [PATCH v2 3/3] wifi: cfg80211: check if AP has been started or joined a mesh before adding new station Slawomir Stepien
  1 sibling, 0 replies; 3+ messages in thread
From: Slawomir Stepien @ 2026-09-10  8:04 UTC (permalink / raw)
  To: syzkaller-bugs, johannes, linux-wireless
  Cc: linux-kernel, syzbot, sst, syzbot+9bdc0c5998ab45b05030

I do not see a reason why this check is so low in the function. Move it
up right next to param fetch.

This new position is more beneficial for AP/Link state check that will
be added in upcoming commit.

Signed-off-by: Slawomir Stepien <sst@poczta.fm>
---
v2:
* No changes

v1:
* https://lore.kernel.org/all/20260813090434.2071318-2-sst@poczta.fm/
---
 net/wireless/nl80211.c | 27 ++++++++++-----------------
 1 file changed, 10 insertions(+), 17 deletions(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index fd784fa3fff8..8f7238415047 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -9376,6 +9376,16 @@ static int nl80211_new_station(struct sk_buff *skb, struct genl_info *info)
 	params.link_sta_params.link_id =
 		nl80211_link_id_or_invalid(info->attrs);
 
+	if (wdev->valid_links) {
+		if (params.link_sta_params.link_id < 0)
+			return -EINVAL;
+		if (!(wdev->valid_links & BIT(params.link_sta_params.link_id)))
+			return -ENOLINK;
+	} else {
+		if (params.link_sta_params.link_id >= 0)
+			return -EINVAL;
+	}
+
 	if (info->attrs[NL80211_ATTR_MLD_ADDR]) {
 		mac_addr = nla_data(info->attrs[NL80211_ATTR_MLD_ADDR]);
 		params.link_sta_params.mld_mac = mac_addr;
@@ -9648,27 +9658,10 @@ static int nl80211_new_station(struct sk_buff *skb, struct genl_info *info)
 
 	/* be aware of params.vlan when changing code here */
 
-	if (wdev->valid_links) {
-		if (params.link_sta_params.link_id < 0) {
-			err = -EINVAL;
-			goto out;
-		}
-		if (!(wdev->valid_links & BIT(params.link_sta_params.link_id))) {
-			err = -ENOLINK;
-			goto out;
-		}
-	} else {
-		if (params.link_sta_params.link_id >= 0) {
-			err = -EINVAL;
-			goto out;
-		}
-	}
-
 	params.epp_peer =
 		nla_get_flag(info->attrs[NL80211_ATTR_EPP_PEER]);
 
 	err = rdev_add_station(rdev, wdev, mac_addr, &params);
-out:
 	dev_put(params.vlan);
 	return err;
 }
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH v2 3/3] wifi: cfg80211: check if AP has been started or joined a mesh before adding new station
  2026-09-10  8:04 [PATCH v2 1/3] wifi: cfg80211: do not support direct add of station to AP_VLAN interfaces Slawomir Stepien
  2026-09-10  8:04 ` [PATCH v2 2/3] wifi: cfg80211: move link_id validation earlier in nl80211_new_station() Slawomir Stepien
@ 2026-09-10  8:04 ` Slawomir Stepien
  1 sibling, 0 replies; 3+ messages in thread
From: Slawomir Stepien @ 2026-09-10  8:04 UTC (permalink / raw)
  To: syzkaller-bugs, johannes, linux-wireless
  Cc: linux-kernel, syzbot, sst, syzbot+9bdc0c5998ab45b05030

Adding a new station to AP makes only sense when the AP has been started
(nl80211_start_ap()) or joined a mesh (__cfg80211_join_mesh()).

Check if AP is up and beaconing on the link or joined the mesh, when
adding new station. Return error if this isn't the case.

Note that libertas devices need special handling since they do not
implement join_mesh() and the decision must be made on channel
definition.

Reported-by: syzbot+9bdc0c5998ab45b05030@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=9bdc0c5998ab45b05030
Signed-off-by: Slawomir Stepien <sst@poczta.fm>
---
v2:
* Add mesh handling (inc. libertas devices special case)

v1:
* https://lore.kernel.org/all/20260813090434.2071318-3-sst@poczta.fm/
---
 net/wireless/nl80211.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 8f7238415047..fca19e1d0c9a 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -9328,7 +9328,7 @@ static int nl80211_set_station(struct sk_buff *skb, struct genl_info *info)
 static int nl80211_new_station(struct sk_buff *skb, struct genl_info *info)
 {
 	struct cfg80211_registered_device *rdev = info->user_ptr[0];
-	int err;
+	int err, link_id;
 	struct wireless_dev *wdev = info->user_ptr[1];
 	struct net_device *dev = wdev->netdev;
 	struct station_parameters params;
@@ -9567,6 +9567,11 @@ static int nl80211_new_station(struct sk_buff *skb, struct genl_info *info)
 	switch (wdev->iftype) {
 	case NL80211_IFTYPE_AP:
 	case NL80211_IFTYPE_P2P_GO:
+		/* Add a new station only after the AP and link has been started */
+		link_id = wdev->valid_links ? params.link_sta_params.link_id : 0;
+		if (!wdev->links[link_id].ap.beacon_interval)
+			return -ENETDOWN;
+
 		/* ignore WME attributes if iface/sta is not capable */
 		if (!(rdev->wiphy.flags & WIPHY_FLAG_AP_UAPSD) ||
 		    !(params.sta_flags_set & BIT(NL80211_STA_FLAG_WME)))
@@ -9611,6 +9616,19 @@ static int nl80211_new_station(struct sk_buff *skb, struct genl_info *info)
 			return PTR_ERR(params.vlan);
 		break;
 	case NL80211_IFTYPE_MESH_POINT:
+		/*
+		 * Add a new station only after the mesh has been started.
+		 * libertas doesn't implement join_mesh(); it configures the
+		 * mesh via sysfs and joins it when the channel is set, so
+		 * use that as the started indication instead.
+		 */
+		if (rdev->ops->libertas_set_mesh_channel) {
+			if (!wdev->u.mesh.chandef.chan)
+				return -ENETDOWN;
+		} else if (!wdev->u.mesh.beacon_interval) {
+			return -ENETDOWN;
+		}
+
 		/* ignore uAPSD data */
 		params.sta_modify_mask &= ~STATION_PARAM_APPLY_UAPSD;
 
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-09-10  8:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-10  8:04 [PATCH v2 1/3] wifi: cfg80211: do not support direct add of station to AP_VLAN interfaces Slawomir Stepien
2026-09-10  8:04 ` [PATCH v2 2/3] wifi: cfg80211: move link_id validation earlier in nl80211_new_station() Slawomir Stepien
2026-09-10  8:04 ` [PATCH v2 3/3] wifi: cfg80211: check if AP has been started or joined a mesh before adding new station Slawomir Stepien

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox