Skip to content

Commit 52cebab

Browse files
nbd168jmberg-intel
authored andcommitted
wifi: mac80211: fix vif addr when switching from monitor to station
Since adding support for opting out of virtual monitor support, a zero vif addr was used to indicate passive vs active monitor to the driver. This would break the vif->addr when changing the netdev mac address before switching the interface from monitor to sta mode. Fix the regression by adding a separate flag to indicate whether vif->addr is valid. Reported-by: syzbot+9ea265d998de25ac6a46@syzkaller.appspotmail.com Fixes: 9d40f7e ("wifi: mac80211: add flag to opt out of virtual monitor support") Signed-off-by: Felix Fietkau <nbd@nbd.name> Link: https://patch.msgid.link/20241115115850.37449-1-nbd@nbd.name Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent 11ac0d7 commit 52cebab

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

include/net/mac80211.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1987,6 +1987,8 @@ enum ieee80211_neg_ttlm_res {
19871987
* @neg_ttlm: negotiated TID to link mapping info.
19881988
* see &struct ieee80211_neg_ttlm.
19891989
* @addr: address of this interface
1990+
* @addr_valid: indicates if the address is actively used. Set to false for
1991+
* passive monitor interfaces, true in all other cases.
19901992
* @p2p: indicates whether this AP or STA interface is a p2p
19911993
* interface, i.e. a GO or p2p-sta respectively
19921994
* @netdev_features: tx netdev features supported by the hardware for this
@@ -2026,6 +2028,7 @@ struct ieee80211_vif {
20262028
u16 valid_links, active_links, dormant_links, suspended_links;
20272029
struct ieee80211_neg_ttlm neg_ttlm;
20282030
u8 addr[ETH_ALEN] __aligned(2);
2031+
bool addr_valid;
20292032
bool p2p;
20302033

20312034
u8 cab_queue;

net/mac80211/iface.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -278,13 +278,8 @@ static int _ieee80211_change_mac(struct ieee80211_sub_if_data *sdata,
278278
ret = eth_mac_addr(sdata->dev, sa);
279279

280280
if (ret == 0) {
281-
if (check_dup) {
282-
memcpy(sdata->vif.addr, sa->sa_data, ETH_ALEN);
283-
ether_addr_copy(sdata->vif.bss_conf.addr, sdata->vif.addr);
284-
} else {
285-
memset(sdata->vif.addr, 0, ETH_ALEN);
286-
memset(sdata->vif.bss_conf.addr, 0, ETH_ALEN);
287-
}
281+
memcpy(sdata->vif.addr, sa->sa_data, ETH_ALEN);
282+
ether_addr_copy(sdata->vif.bss_conf.addr, sdata->vif.addr);
288283
}
289284

290285
/* Regardless of eth_mac_addr() return we still want to add the
@@ -1323,6 +1318,8 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
13231318
}
13241319
}
13251320

1321+
sdata->vif.addr_valid = sdata->vif.type != NL80211_IFTYPE_MONITOR ||
1322+
(sdata->u.mntr.flags & MONITOR_FLAG_ACTIVE);
13261323
switch (sdata->vif.type) {
13271324
case NL80211_IFTYPE_AP_VLAN:
13281325
/* no need to tell driver, but set carrier and chanctx */

0 commit comments

Comments
 (0)