wifi: cfg80211: fix MLO connection ownership

[ Upstream commit 96c0695083 ]

When disconnecting from an MLO connection we need the AP
MLD address, not an arbitrary BSSID. Fix the code to do
that.

Fixes: 9ecff10e82 ("wifi: nl80211: refactor BSS lookup in nl80211_associate()")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20230301115906.4c1b3b18980e.I008f070c7f3b8e8bde9278101ef9e40706a82902@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Johannes Berg 2023-03-01 12:09:33 +02:00 committed by Greg Kroah-Hartman
parent 87e80ea4fb
commit dcf94604d4
1 changed files with 7 additions and 9 deletions

View File

@ -10699,8 +10699,7 @@ static int nl80211_crypto_settings(struct cfg80211_registered_device *rdev,
static struct cfg80211_bss *nl80211_assoc_bss(struct cfg80211_registered_device *rdev, static struct cfg80211_bss *nl80211_assoc_bss(struct cfg80211_registered_device *rdev,
const u8 *ssid, int ssid_len, const u8 *ssid, int ssid_len,
struct nlattr **attrs, struct nlattr **attrs)
const u8 **bssid_out)
{ {
struct ieee80211_channel *chan; struct ieee80211_channel *chan;
struct cfg80211_bss *bss; struct cfg80211_bss *bss;
@ -10727,7 +10726,6 @@ static struct cfg80211_bss *nl80211_assoc_bss(struct cfg80211_registered_device
if (!bss) if (!bss)
return ERR_PTR(-ENOENT); return ERR_PTR(-ENOENT);
*bssid_out = bssid;
return bss; return bss;
} }
@ -10737,7 +10735,7 @@ static int nl80211_associate(struct sk_buff *skb, struct genl_info *info)
struct net_device *dev = info->user_ptr[1]; struct net_device *dev = info->user_ptr[1];
struct cfg80211_assoc_request req = {}; struct cfg80211_assoc_request req = {};
struct nlattr **attrs = NULL; struct nlattr **attrs = NULL;
const u8 *bssid, *ssid; const u8 *ap_addr, *ssid;
unsigned int link_id; unsigned int link_id;
int err, ssid_len; int err, ssid_len;
@ -10874,6 +10872,7 @@ static int nl80211_associate(struct sk_buff *skb, struct genl_info *info)
return -EINVAL; return -EINVAL;
req.ap_mld_addr = nla_data(info->attrs[NL80211_ATTR_MLD_ADDR]); req.ap_mld_addr = nla_data(info->attrs[NL80211_ATTR_MLD_ADDR]);
ap_addr = req.ap_mld_addr;
attrs = kzalloc(attrsize, GFP_KERNEL); attrs = kzalloc(attrsize, GFP_KERNEL);
if (!attrs) if (!attrs)
@ -10899,8 +10898,7 @@ static int nl80211_associate(struct sk_buff *skb, struct genl_info *info)
goto free; goto free;
} }
req.links[link_id].bss = req.links[link_id].bss =
nl80211_assoc_bss(rdev, ssid, ssid_len, attrs, nl80211_assoc_bss(rdev, ssid, ssid_len, attrs);
&bssid);
if (IS_ERR(req.links[link_id].bss)) { if (IS_ERR(req.links[link_id].bss)) {
err = PTR_ERR(req.links[link_id].bss); err = PTR_ERR(req.links[link_id].bss);
req.links[link_id].bss = NULL; req.links[link_id].bss = NULL;
@ -10951,10 +10949,10 @@ static int nl80211_associate(struct sk_buff *skb, struct genl_info *info)
if (req.link_id >= 0) if (req.link_id >= 0)
return -EINVAL; return -EINVAL;
req.bss = nl80211_assoc_bss(rdev, ssid, ssid_len, info->attrs, req.bss = nl80211_assoc_bss(rdev, ssid, ssid_len, info->attrs);
&bssid);
if (IS_ERR(req.bss)) if (IS_ERR(req.bss))
return PTR_ERR(req.bss); return PTR_ERR(req.bss);
ap_addr = req.bss->bssid;
} }
err = nl80211_crypto_settings(rdev, info, &req.crypto, 1); err = nl80211_crypto_settings(rdev, info, &req.crypto, 1);
@ -10967,7 +10965,7 @@ static int nl80211_associate(struct sk_buff *skb, struct genl_info *info)
dev->ieee80211_ptr->conn_owner_nlportid = dev->ieee80211_ptr->conn_owner_nlportid =
info->snd_portid; info->snd_portid;
memcpy(dev->ieee80211_ptr->disconnect_bssid, memcpy(dev->ieee80211_ptr->disconnect_bssid,
bssid, ETH_ALEN); ap_addr, ETH_ALEN);
} }
wdev_unlock(dev->ieee80211_ptr); wdev_unlock(dev->ieee80211_ptr);