Skip to content
This repository was archived by the owner on Dec 20, 2023. It is now read-only.

Commit 252e07c

Browse files
lucacoelhojmberg-intel
authored andcommitted
nl80211: sanity check the channel switch counter value
The nl80211 channel switch count attribute (NL80211_ATTR_CH_SWITCH_COUNT) is specified as u32, but the specification uses u8 for the counter. To make sure strange things don't happen without informing the user, sanity check the value and return -EINVAL if it doesn't fit in u8. Signed-off-by: Luciano Coelho <luciano.coelho@intel.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent bc37b16 commit 252e07c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

net/wireless/nl80211.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5927,6 +5927,7 @@ static int nl80211_channel_switch(struct sk_buff *skb, struct genl_info *info)
59275927
int err;
59285928
bool need_new_beacon = false;
59295929
int len, i;
5930+
u32 cs_count;
59305931

59315932
if (!rdev->ops->channel_switch ||
59325933
!(rdev->wiphy.flags & WIPHY_FLAG_HAS_CHANNEL_SWITCH))
@@ -5963,7 +5964,14 @@ static int nl80211_channel_switch(struct sk_buff *skb, struct genl_info *info)
59635964
if (need_new_beacon && !info->attrs[NL80211_ATTR_CSA_IES])
59645965
return -EINVAL;
59655966

5966-
params.count = nla_get_u32(info->attrs[NL80211_ATTR_CH_SWITCH_COUNT]);
5967+
/* Even though the attribute is u32, the specification says
5968+
* u8, so let's make sure we don't overflow.
5969+
*/
5970+
cs_count = nla_get_u32(info->attrs[NL80211_ATTR_CH_SWITCH_COUNT]);
5971+
if (cs_count > 255)
5972+
return -EINVAL;
5973+
5974+
params.count = cs_count;
59675975

59685976
if (!need_new_beacon)
59695977
goto skip_beacons;

0 commit comments

Comments
 (0)