3f04c93c0a9b0fd3b6ca351bbcdb18c53f7ba942
[openwrt/staging/ansuel.git] /
1 From 2ae5c9248e06dac2c2360be26b4e25f673238337 Mon Sep 17 00:00:00 2001
2 From: Jeff Johnson <quic_jjohnson@quicinc.com>
3 Date: Thu, 31 Aug 2023 11:22:58 -0700
4 Subject: [PATCH] wifi: mac80211: Use flexible array in struct ieee80211_tim_ie
5
6 Currently struct ieee80211_tim_ie defines:
7 u8 virtual_map[1];
8
9 Per the guidance in [1] change this to be a flexible array.
10
11 Per the discussion in [2] wrap the virtual_map in a union with a u8
12 item in order to preserve the existing expectation that the
13 virtual_map must contain at least one octet (at least when used in a
14 non-S1G PPDU). This means that no driver changes are required.
15
16 [1] https://docs.kernel.org/process/deprecated.html#zero-length-and-one-element-arrays
17 [2] https://lore.kernel.org/linux-wireless/202308301529.AC90A9EF98@keescook/
18
19 Suggested-by: Kees Cook <keescook@chromium.org>
20 Signed-off-by: Jeff Johnson <quic_jjohnson@quicinc.com>
21 Reviewed-by: Kees Cook <keescook@chromium.org>
22 Link: https://lore.kernel.org/r/20230831-ieee80211_tim_ie-v3-2-e10ff584ab5d@quicinc.com
23 [add wifi prefix]
24 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
25 ---
26 include/linux/ieee80211.h | 13 ++++++++++---
27 1 file changed, 10 insertions(+), 3 deletions(-)
28
29 --- a/include/linux/ieee80211.h
30 +++ b/include/linux/ieee80211.h
31 @@ -951,17 +951,24 @@ struct ieee80211_wide_bw_chansw_ie {
32 * @dtim_count: DTIM Count
33 * @dtim_period: DTIM Period
34 * @bitmap_ctrl: Bitmap Control
35 + * @required_octet: "Syntatic sugar" to force the struct size to the
36 + * minimum valid size when carried in a non-S1G PPDU
37 * @virtual_map: Partial Virtual Bitmap
38 *
39 * This structure represents the payload of the "TIM element" as
40 - * described in IEEE Std 802.11-2020 section 9.4.2.5.
41 + * described in IEEE Std 802.11-2020 section 9.4.2.5. Note that this
42 + * definition is only applicable when the element is carried in a
43 + * non-S1G PPDU. When the TIM is carried in an S1G PPDU, the Bitmap
44 + * Control and Partial Virtual Bitmap may not be present.
45 */
46 struct ieee80211_tim_ie {
47 u8 dtim_count;
48 u8 dtim_period;
49 u8 bitmap_ctrl;
50 - /* variable size: 1 - 251 bytes */
51 - u8 virtual_map[1];
52 + union {
53 + u8 required_octet;
54 + DECLARE_FLEX_ARRAY(u8, virtual_map);
55 + };
56 } __packed;
57
58 /**