generic: replace simple AQR hack patch with upstream version
[openwrt/staging/jow.git] / package / kernel / mac80211 / patches / subsys / 311-mac80211-fix-mesh-id-corruption-on-32-bit-systems.patch
1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Tue, 12 Sep 2023 15:09:27 +0200
3 Subject: [PATCH] mac80211: fix mesh id corruption on 32 bit systems
4 MIME-Version: 1.0
5 Content-Type: text/plain; charset=UTF-8
6 Content-Transfer-Encoding: 8bit
7
8 Since the changed field size was increased to u64, mesh_bss_info_changed
9 pulls invalid bits from the first 3 bytes of the mesh id, clears them, and
10 passes them on to ieee80211_link_info_change_notify, because
11 ifmsh->mbss_changed was not updated to match its size.
12 Fix this by turning into ifmsh->mbss_changed into an unsigned long array with
13 64 bit size.
14
15 Fixes: 15ddba5f4311 ("wifi: mac80211: consistently use u64 for BSS changes")
16 Reported-by: Thomas Hühn <thomas.huehn@hs-nordhausen.de>
17 Signed-off-by: Felix Fietkau <nbd@nbd.name>
18 ---
19
20 --- a/net/mac80211/ieee80211_i.h
21 +++ b/net/mac80211/ieee80211_i.h
22 @@ -678,7 +678,7 @@ struct ieee80211_if_mesh {
23 struct timer_list mesh_path_root_timer;
24
25 unsigned long wrkq_flags;
26 - unsigned long mbss_changed;
27 + unsigned long mbss_changed[64 / BITS_PER_LONG];
28
29 bool userspace_handles_dfs;
30
31 --- a/net/mac80211/mesh.c
32 +++ b/net/mac80211/mesh.c
33 @@ -1181,7 +1181,7 @@ void ieee80211_mbss_info_change_notify(s
34
35 /* if we race with running work, worst case this work becomes a noop */
36 for_each_set_bit(bit, &bits, sizeof(changed) * BITS_PER_BYTE)
37 - set_bit(bit, &ifmsh->mbss_changed);
38 + set_bit(bit, ifmsh->mbss_changed);
39 set_bit(MESH_WORK_MBSS_CHANGED, &ifmsh->wrkq_flags);
40 wiphy_work_queue(sdata->local->hw.wiphy, &sdata->work);
41 }
42 @@ -1263,7 +1263,7 @@ void ieee80211_stop_mesh(struct ieee8021
43
44 /* clear any mesh work (for next join) we may have accrued */
45 ifmsh->wrkq_flags = 0;
46 - ifmsh->mbss_changed = 0;
47 + memset(ifmsh->mbss_changed, 0, sizeof(ifmsh->mbss_changed));
48
49 local->fif_other_bss--;
50 atomic_dec(&local->iff_allmultis);
51 @@ -1730,9 +1730,9 @@ static void mesh_bss_info_changed(struct
52 u32 bit;
53 u64 changed = 0;
54
55 - for_each_set_bit(bit, &ifmsh->mbss_changed,
56 + for_each_set_bit(bit, ifmsh->mbss_changed,
57 sizeof(changed) * BITS_PER_BYTE) {
58 - clear_bit(bit, &ifmsh->mbss_changed);
59 + clear_bit(bit, ifmsh->mbss_changed);
60 changed |= BIT(bit);
61 }
62