diff options
author | Luciano Coelho <luciano.coelho@intel.com> | 2014-10-08 02:48:34 -0400 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2014-10-09 05:25:11 -0400 |
commit | 252e07ca5f64dd31fdfca8027287e7d75fefdab1 (patch) | |
tree | cf5564c90befa418c6d2adedb495747505db90b4 /net/wireless | |
parent | bc37b16870a382e8b71d881444c19a16de1c1a7f (diff) |
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>
Diffstat (limited to 'net/wireless')
-rw-r--r-- | net/wireless/nl80211.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index cb9f5a44ffad..5839c85075f1 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c | |||
@@ -5927,6 +5927,7 @@ static int nl80211_channel_switch(struct sk_buff *skb, struct genl_info *info) | |||
5927 | int err; | 5927 | int err; |
5928 | bool need_new_beacon = false; | 5928 | bool need_new_beacon = false; |
5929 | int len, i; | 5929 | int len, i; |
5930 | u32 cs_count; | ||
5930 | 5931 | ||
5931 | if (!rdev->ops->channel_switch || | 5932 | if (!rdev->ops->channel_switch || |
5932 | !(rdev->wiphy.flags & WIPHY_FLAG_HAS_CHANNEL_SWITCH)) | 5933 | !(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) | |||
5963 | if (need_new_beacon && !info->attrs[NL80211_ATTR_CSA_IES]) | 5964 | if (need_new_beacon && !info->attrs[NL80211_ATTR_CSA_IES]) |
5964 | return -EINVAL; | 5965 | return -EINVAL; |
5965 | 5966 | ||
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; | ||
5967 | 5975 | ||
5968 | if (!need_new_beacon) | 5976 | if (!need_new_beacon) |
5969 | goto skip_beacons; | 5977 | goto skip_beacons; |