f4cfc95aa3b7a195debec43628657148cf72bbf6
[openwrt/openwrt.git] /
1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Fri, 15 Nov 2024 12:28:43 +0100
3 Subject: [PATCH] wifi: mac80211: fix vif addr when switching from monitor
4 to station
5
6 Since adding support for opting out of virtual monitor support, a zero vif
7 addr was used to indicate passive vs active monitor to the driver.
8 This would break the vif->addr when changing the netdev mac address before
9 switching the interface from monitor to sta mode.
10 Fix the regression by adding a separate flag to indicate whether vif->addr
11 is valid.
12
13 Reported-by: syzbot+9ea265d998de25ac6a46@syzkaller.appspotmail.com
14 Fixes: 9d40f7e32774 ("wifi: mac80211: add flag to opt out of virtual monitor support")
15 Signed-off-by: Felix Fietkau <nbd@nbd.name>
16 ---
17
18 --- a/include/net/mac80211.h
19 +++ b/include/net/mac80211.h
20 @@ -1972,6 +1972,8 @@ enum ieee80211_neg_ttlm_res {
21 * @neg_ttlm: negotiated TID to link mapping info.
22 * see &struct ieee80211_neg_ttlm.
23 * @addr: address of this interface
24 + * @addr_valid: indicates if the address is actively used. Set to false for
25 + * passive monitor interfaces, true in all other cases.
26 * @p2p: indicates whether this AP or STA interface is a p2p
27 * interface, i.e. a GO or p2p-sta respectively
28 * @netdev_features: tx netdev features supported by the hardware for this
29 @@ -2011,6 +2013,7 @@ struct ieee80211_vif {
30 u16 valid_links, active_links, dormant_links, suspended_links;
31 struct ieee80211_neg_ttlm neg_ttlm;
32 u8 addr[ETH_ALEN] __aligned(2);
33 + bool addr_valid;
34 bool p2p;
35
36 u8 cab_queue;
37 --- a/net/mac80211/iface.c
38 +++ b/net/mac80211/iface.c
39 @@ -279,13 +279,8 @@ static int _ieee80211_change_mac(struct
40 ret = eth_mac_addr(sdata->dev, sa);
41
42 if (ret == 0) {
43 - if (check_dup) {
44 - memcpy(sdata->vif.addr, sa->sa_data, ETH_ALEN);
45 - ether_addr_copy(sdata->vif.bss_conf.addr, sdata->vif.addr);
46 - } else {
47 - memset(sdata->vif.addr, 0, ETH_ALEN);
48 - memset(sdata->vif.bss_conf.addr, 0, ETH_ALEN);
49 - }
50 + memcpy(sdata->vif.addr, sa->sa_data, ETH_ALEN);
51 + ether_addr_copy(sdata->vif.bss_conf.addr, sdata->vif.addr);
52 }
53
54 /* Regardless of eth_mac_addr() return we still want to add the
55 @@ -1324,6 +1319,8 @@ int ieee80211_do_open(struct wireless_de
56 }
57 }
58
59 + sdata->vif.addr_valid = sdata->vif.type != NL80211_IFTYPE_MONITOR ||
60 + (sdata->u.mntr.flags & MONITOR_FLAG_ACTIVE);
61 switch (sdata->vif.type) {
62 case NL80211_IFTYPE_AP_VLAN:
63 /* no need to tell driver, but set carrier and chanctx */