Re: [PATCH v2] mac80211: reject station addition if AP or MLO link is inactive

Slawomir Stepien <[email protected]> Mon, 27 Jul 2026 15:26:40 +0200
Newsgroups dev.linux.lists.syzbot,org.kernel.vger.linux-kernel,org.kernel.vger.linux-wireless
Message-ID <amdckJhgBz7xT2F7@nr200>
On lip 27, 2026 12:26, Slawomir Stepien wrote:
> On lip 27, 2026 11:25, Johannes Berg wrote:
> > On Mon, 2026-07-27 at 11:22 +0200, Slawomir Stepien wrote:
> > > 
> > > I think we do not have. I'm looking at the struct wireless_dev fields and I see that there is just
> > > info about what the configuration should be, not info about what is the current state of the device.
> > > I also do not see any callback in struct cfg80211_ops that might help to get such info. If I'm wrong
> > > then please correct my observation!
> > 
> > I think we maintain wdev->links[].ap.beacon_interval?
> 
> Ah: https://elixir.bootlin.com/linux/v7.1.4/source/net/wireless/nl80211.c#L7188 and
> https://elixir.bootlin.com/linux/v7.1.4/source/net/wireless/ap.c#L36. Ok! Let me try using that in
> v3 then. Thanks!

After taking a closer look at this I wonder how AP_VLAN should be handled? Is there a way on
cfg80211 level to be able to check AP_VLAN's main device state?

My code change would look something like this:

@@ -9404,6 +9404,12 @@ static int nl80211_new_station(struct sk_buff *skb, struct genl_info *info)
        case NL80211_IFTYPE_AP:
        case NL80211_IFTYPE_AP_VLAN:
        case NL80211_IFTYPE_P2P_GO:
+               /* Add new station only after the AP and link has been started */
+               int link = params.link_sta_params.link_id >= 0 ?
+                          params.link_sta_params.link_id : 0;
+               if (!wdev->links[link].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)))

but the NL80211_IFTYPE_AP_VLAN case would not work here, right? Can I just do the checking only for
NL80211_IFTYPE_AP and NL80211_IFTYPE_P2P_GO and skip NL80211_IFTYPE_AP_VLAN?

-- 
Slawomir Stepien