include/linux/ieee80211.h | 2 +- net/mac80211/mlme.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
According to ieee80211_s1g_optional_len(), it can be clearly seen that the
maximum size of variable is 4 and it is an array. Based on the above, the
parsing of the frame control field and optional field is optimized.
Fixes: 1e1f706fc2ce ("wifi: cfg80211/mac80211: correctly parse S1G beacon optional elements")
Reported-by: syzbot+6554b492c7008bcd3385@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=6554b492c7008bcd3385
Tested-by: syzbot+6554b492c7008bcd3385@syzkaller.appspotmail.com
Signed-off-by: Edward Adam Davis <eadavis@qq.com>
---
include/linux/ieee80211.h | 2 +-
net/mac80211/mlme.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h
index ce377f7fb912..556ce95e0b0f 100644
--- a/include/linux/ieee80211.h
+++ b/include/linux/ieee80211.h
@@ -1278,7 +1278,7 @@ struct ieee80211_ext {
u8 sa[ETH_ALEN];
__le32 timestamp;
u8 change_seq;
- u8 variable[0];
+ u8 variable[4];
} __packed s1g_beacon;
} u;
} __packed __aligned(2);
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 2d46d4af60d7..fb7bf95ee87b 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -7222,7 +7222,7 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_link_data *link,
if (ieee80211_is_s1g_beacon(mgmt->frame_control)) {
struct ieee80211_ext *ext = (void *) mgmt;
variable = ext->u.s1g_beacon.variable +
- ieee80211_s1g_optional_len(ext->frame_control);
+ (ieee80211_s1g_optional_len(ext->frame_control) - 1);
}
baselen = (u8 *) variable - (u8 *) mgmt;
--
2.43.0
On Tue, Jun 17, 2025 at 12:41:33PM +0800, Edward Adam Davis wrote: > According to ieee80211_s1g_optional_len(), it can be clearly seen that the > maximum size of variable is 4 and it is an array. Based on the above, the > parsing of the frame control field and optional field is optimized. Hi, This is incorrect according to IEEE80211-2024 9.3.4.3. In addition, the undefined behaviour reported by the bot due to using zero length arrays rather then variable length arrays already has a patch submitted by Johanes - please see: Link: https://patchwork.kernel.org/project/linux-wireless/patch/20250614003037.a3e82e882251.I2e8b58e56ff2a9f8b06c66f036578b7c1d4e4685@changeid/ lachlan
On Tue, 2025-06-17 at 12:41 +0800, Edward Adam Davis wrote: > According to ieee80211_s1g_optional_len(), it can be clearly seen that the > maximum size of variable is 4 and it is an array. Based on the above, the > parsing of the frame control field and optional field is optimized. > > Fixes: 1e1f706fc2ce ("wifi: cfg80211/mac80211: correctly parse S1G beacon optional elements") > Reported-by: syzbot+6554b492c7008bcd3385@syzkaller.appspotmail.com > Closes: https://syzkaller.appspot.com/bug?extid=6554b492c7008bcd3385 > Tested-by: syzbot+6554b492c7008bcd3385@syzkaller.appspotmail.com > Signed-off-by: Edward Adam Davis <eadavis@qq.com> > --- > include/linux/ieee80211.h | 2 +- > net/mac80211/mlme.c | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h > index ce377f7fb912..556ce95e0b0f 100644 > --- a/include/linux/ieee80211.h > +++ b/include/linux/ieee80211.h > @@ -1278,7 +1278,7 @@ struct ieee80211_ext { > u8 sa[ETH_ALEN]; > __le32 timestamp; > u8 change_seq; > - u8 variable[0]; > + u8 variable[4]; That's incorrect when those fields aren't present, and will result in wrong sizeof(). I believe the correct fix is one I sent before, to just make it []: https://lore.kernel.org/linux-wireless/20250614003037.a3e82e882251.I2e8b58e56ff2a9f8b06c66f036578b7c1d4e4685@changeid/ johannes
© 2016 - 2025 Red Hat, Inc.