diff options
author | Marco Porsch <marco@cozybit.com> | 2013-01-07 10:04:48 -0500 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2013-01-16 16:40:20 -0500 |
commit | ea54fba20985b7a0cb8e1c8e2760a0865ee47763 (patch) | |
tree | 8f014e95294f5c37407b680b48986935b157273b /net/wireless | |
parent | ee1f668136b2fb6640ee2d54c2a525ea41f98211 (diff) |
nl80211: add range checks to mesh parameters
Ranges are taken from IEEE 802.11-2012, common sense or current
implementation requirements.
Signed-off-by: Marco Porsch <marco@cozybit.com>
Acked-by: Thomas Pedersen <thomas@cozybit.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/wireless')
-rw-r--r-- | net/wireless/nl80211.c | 79 |
1 files changed, 44 insertions, 35 deletions
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 9bd8340af999..ceb27fda9ec5 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c | |||
@@ -3981,13 +3981,15 @@ static int nl80211_parse_mesh_config(struct genl_info *info, | |||
3981 | struct nlattr *tb[NL80211_MESHCONF_ATTR_MAX + 1]; | 3981 | struct nlattr *tb[NL80211_MESHCONF_ATTR_MAX + 1]; |
3982 | u32 mask = 0; | 3982 | u32 mask = 0; |
3983 | 3983 | ||
3984 | #define FILL_IN_MESH_PARAM_IF_SET(table, cfg, param, mask, attr_num, nla_fn) \ | 3984 | #define FILL_IN_MESH_PARAM_IF_SET(tb, cfg, param, min, max, mask, attr, fn) \ |
3985 | do {\ | 3985 | do { \ |
3986 | if (table[attr_num]) {\ | 3986 | if (tb[attr]) { \ |
3987 | cfg->param = nla_fn(table[attr_num]); \ | 3987 | if (fn(tb[attr]) < min || fn(tb[attr]) > max) \ |
3988 | mask |= (1 << (attr_num - 1)); \ | 3988 | return -EINVAL; \ |
3989 | } \ | 3989 | cfg->param = fn(tb[attr]); \ |
3990 | } while (0);\ | 3990 | mask |= (1 << (attr - 1)); \ |
3991 | } \ | ||
3992 | } while (0) | ||
3991 | 3993 | ||
3992 | 3994 | ||
3993 | if (!info->attrs[NL80211_ATTR_MESH_CONFIG]) | 3995 | if (!info->attrs[NL80211_ATTR_MESH_CONFIG]) |
@@ -4002,81 +4004,88 @@ do {\ | |||
4002 | BUILD_BUG_ON(NL80211_MESHCONF_ATTR_MAX > 32); | 4004 | BUILD_BUG_ON(NL80211_MESHCONF_ATTR_MAX > 32); |
4003 | 4005 | ||
4004 | /* Fill in the params struct */ | 4006 | /* Fill in the params struct */ |
4005 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshRetryTimeout, | 4007 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshRetryTimeout, 1, 255, |
4006 | mask, NL80211_MESHCONF_RETRY_TIMEOUT, | 4008 | mask, NL80211_MESHCONF_RETRY_TIMEOUT, |
4007 | nla_get_u16); | 4009 | nla_get_u16); |
4008 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshConfirmTimeout, | 4010 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshConfirmTimeout, 1, 255, |
4009 | mask, NL80211_MESHCONF_CONFIRM_TIMEOUT, | 4011 | mask, NL80211_MESHCONF_CONFIRM_TIMEOUT, |
4010 | nla_get_u16); | 4012 | nla_get_u16); |
4011 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHoldingTimeout, | 4013 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHoldingTimeout, 1, 255, |
4012 | mask, NL80211_MESHCONF_HOLDING_TIMEOUT, | 4014 | mask, NL80211_MESHCONF_HOLDING_TIMEOUT, |
4013 | nla_get_u16); | 4015 | nla_get_u16); |
4014 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshMaxPeerLinks, | 4016 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshMaxPeerLinks, 0, 255, |
4015 | mask, NL80211_MESHCONF_MAX_PEER_LINKS, | 4017 | mask, NL80211_MESHCONF_MAX_PEER_LINKS, |
4016 | nla_get_u16); | 4018 | nla_get_u16); |
4017 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshMaxRetries, | 4019 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshMaxRetries, 0, 16, |
4018 | mask, NL80211_MESHCONF_MAX_RETRIES, | 4020 | mask, NL80211_MESHCONF_MAX_RETRIES, |
4019 | nla_get_u8); | 4021 | nla_get_u8); |
4020 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshTTL, | 4022 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshTTL, 1, 255, |
4021 | mask, NL80211_MESHCONF_TTL, nla_get_u8); | 4023 | mask, NL80211_MESHCONF_TTL, nla_get_u8); |
4022 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, element_ttl, | 4024 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, element_ttl, 1, 255, |
4023 | mask, NL80211_MESHCONF_ELEMENT_TTL, | 4025 | mask, NL80211_MESHCONF_ELEMENT_TTL, |
4024 | nla_get_u8); | 4026 | nla_get_u8); |
4025 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, auto_open_plinks, | 4027 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, auto_open_plinks, 0, 1, |
4026 | mask, NL80211_MESHCONF_AUTO_OPEN_PLINKS, | 4028 | mask, NL80211_MESHCONF_AUTO_OPEN_PLINKS, |
4027 | nla_get_u8); | 4029 | nla_get_u8); |
4028 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshNbrOffsetMaxNeighbor, mask, | 4030 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshNbrOffsetMaxNeighbor, |
4031 | 1, 255, mask, | ||
4029 | NL80211_MESHCONF_SYNC_OFFSET_MAX_NEIGHBOR, | 4032 | NL80211_MESHCONF_SYNC_OFFSET_MAX_NEIGHBOR, |
4030 | nla_get_u32); | 4033 | nla_get_u32); |
4031 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPmaxPREQretries, | 4034 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPmaxPREQretries, 0, 255, |
4032 | mask, NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES, | 4035 | mask, NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES, |
4033 | nla_get_u8); | 4036 | nla_get_u8); |
4034 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, path_refresh_time, | 4037 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, path_refresh_time, 1, 65535, |
4035 | mask, NL80211_MESHCONF_PATH_REFRESH_TIME, | 4038 | mask, NL80211_MESHCONF_PATH_REFRESH_TIME, |
4036 | nla_get_u32); | 4039 | nla_get_u32); |
4037 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, min_discovery_timeout, | 4040 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, min_discovery_timeout, 1, 65535, |
4038 | mask, NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT, | 4041 | mask, NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT, |
4039 | nla_get_u16); | 4042 | nla_get_u16); |
4040 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPactivePathTimeout, mask, | 4043 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPactivePathTimeout, |
4044 | 1, 65535, mask, | ||
4041 | NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT, | 4045 | NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT, |
4042 | nla_get_u32); | 4046 | nla_get_u32); |
4043 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPpreqMinInterval, | 4047 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPpreqMinInterval, |
4044 | mask, NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL, | 4048 | 1, 65535, mask, |
4049 | NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL, | ||
4045 | nla_get_u16); | 4050 | nla_get_u16); |
4046 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPperrMinInterval, | 4051 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPperrMinInterval, |
4047 | mask, NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL, | 4052 | 1, 65535, mask, |
4053 | NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL, | ||
4048 | nla_get_u16); | 4054 | nla_get_u16); |
4049 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, | 4055 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, |
4050 | dot11MeshHWMPnetDiameterTraversalTime, mask, | 4056 | dot11MeshHWMPnetDiameterTraversalTime, |
4057 | 1, 65535, mask, | ||
4051 | NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME, | 4058 | NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME, |
4052 | nla_get_u16); | 4059 | nla_get_u16); |
4053 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPRootMode, mask, | 4060 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPRootMode, 0, 4, |
4054 | NL80211_MESHCONF_HWMP_ROOTMODE, nla_get_u8); | 4061 | mask, NL80211_MESHCONF_HWMP_ROOTMODE, |
4055 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPRannInterval, mask, | 4062 | nla_get_u8); |
4056 | NL80211_MESHCONF_HWMP_RANN_INTERVAL, | 4063 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPRannInterval, 1, 65535, |
4064 | mask, NL80211_MESHCONF_HWMP_RANN_INTERVAL, | ||
4057 | nla_get_u16); | 4065 | nla_get_u16); |
4058 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, | 4066 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, |
4059 | dot11MeshGateAnnouncementProtocol, mask, | 4067 | dot11MeshGateAnnouncementProtocol, 0, 1, |
4060 | NL80211_MESHCONF_GATE_ANNOUNCEMENTS, | 4068 | mask, NL80211_MESHCONF_GATE_ANNOUNCEMENTS, |
4061 | nla_get_u8); | 4069 | nla_get_u8); |
4062 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshForwarding, | 4070 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshForwarding, 0, 1, |
4063 | mask, NL80211_MESHCONF_FORWARDING, | 4071 | mask, NL80211_MESHCONF_FORWARDING, |
4064 | nla_get_u8); | 4072 | nla_get_u8); |
4065 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, rssi_threshold, | 4073 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, rssi_threshold, 1, 255, |
4066 | mask, NL80211_MESHCONF_RSSI_THRESHOLD, | 4074 | mask, NL80211_MESHCONF_RSSI_THRESHOLD, |
4067 | nla_get_u32); | 4075 | nla_get_u32); |
4068 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, ht_opmode, | 4076 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, ht_opmode, 0, 16, |
4069 | mask, NL80211_MESHCONF_HT_OPMODE, | 4077 | mask, NL80211_MESHCONF_HT_OPMODE, |
4070 | nla_get_u16); | 4078 | nla_get_u16); |
4071 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPactivePathToRootTimeout, | 4079 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPactivePathToRootTimeout, |
4072 | mask, | 4080 | 1, 65535, mask, |
4073 | NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT, | 4081 | NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT, |
4074 | nla_get_u32); | 4082 | nla_get_u32); |
4075 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMProotInterval, | 4083 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMProotInterval, 1, 65535, |
4076 | mask, NL80211_MESHCONF_HWMP_ROOT_INTERVAL, | 4084 | mask, NL80211_MESHCONF_HWMP_ROOT_INTERVAL, |
4077 | nla_get_u16); | 4085 | nla_get_u16); |
4078 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, | 4086 | FILL_IN_MESH_PARAM_IF_SET(tb, cfg, |
4079 | dot11MeshHWMPconfirmationInterval, mask, | 4087 | dot11MeshHWMPconfirmationInterval, |
4088 | 1, 65535, mask, | ||
4080 | NL80211_MESHCONF_HWMP_CONFIRMATION_INTERVAL, | 4089 | NL80211_MESHCONF_HWMP_CONFIRMATION_INTERVAL, |
4081 | nla_get_u16); | 4090 | nla_get_u16); |
4082 | if (mask_out) | 4091 | if (mask_out) |