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
6 Currently struct ieee80211_tim_ie defines:
9 Per the guidance in [1] change this to be a flexible array.
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.
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/
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
24 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
26 include/linux/ieee80211.h | 13 ++++++++++---
27 1 file changed, 10 insertions(+), 3 deletions(-)
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
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.
46 struct ieee80211_tim_ie {
50 - /* variable size: 1 - 251 bytes */
54 + DECLARE_FLEX_ARRAY(u8, virtual_map);