summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOmer Efrat <omer.efrat@tandemg.com>2018-06-17 06:06:14 -0400
committerJohannes Berg <johannes.berg@intel.com>2018-06-29 03:52:23 -0400
commit397c657a0644e7607c6aebea84d2b0f08ab59dfc (patch)
tree54ea0597e0fa0384a1ed4abc539468e025f371a7
parentf0c0407d2a9fc3b2be33ec6c67ebc1f73595d2cb (diff)
cfg80211: use BIT_ULL for NL80211_STA_INFO_* attribute types
The BIT macro uses unsigned long which some architectures handle as 32 bit and therefore might cause macro's shift to overflow when used on a value equals or larger than 32 (NL80211_STA_INFO_RX_DURATION and afterwards). Since 'filled' member in station_info changed to u64, BIT_ULL macro should be used with all NL80211_STA_INFO_* attribute types instead of BIT to prevent future possible bugs when one will use BIT macro for higher attributes by mistake. This commit cleans up all usages of BIT macro with the above field in cfg80211 by changing it to BIT_ULL instead. In addition, there are some places which don't use BIT nor BIT_ULL macros so align those as well. Signed-off-by: Omer Efrat <omer.efrat@tandemg.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
-rw-r--r--net/wireless/nl80211.c26
-rw-r--r--net/wireless/wext-compat.c10
2 files changed, 18 insertions, 18 deletions
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 0ccce338a66e..350d2962524c 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -4619,13 +4619,13 @@ static int nl80211_send_station(struct sk_buff *msg, u32 cmd, u32 portid,
4619 4619
4620#define PUT_SINFO(attr, memb, type) do { \ 4620#define PUT_SINFO(attr, memb, type) do { \
4621 BUILD_BUG_ON(sizeof(type) == sizeof(u64)); \ 4621 BUILD_BUG_ON(sizeof(type) == sizeof(u64)); \
4622 if (sinfo->filled & (1ULL << NL80211_STA_INFO_ ## attr) && \ 4622 if (sinfo->filled & BIT_ULL(NL80211_STA_INFO_ ## attr) && \
4623 nla_put_ ## type(msg, NL80211_STA_INFO_ ## attr, \ 4623 nla_put_ ## type(msg, NL80211_STA_INFO_ ## attr, \
4624 sinfo->memb)) \ 4624 sinfo->memb)) \
4625 goto nla_put_failure; \ 4625 goto nla_put_failure; \
4626 } while (0) 4626 } while (0)
4627#define PUT_SINFO_U64(attr, memb) do { \ 4627#define PUT_SINFO_U64(attr, memb) do { \
4628 if (sinfo->filled & (1ULL << NL80211_STA_INFO_ ## attr) && \ 4628 if (sinfo->filled & BIT_ULL(NL80211_STA_INFO_ ## attr) && \
4629 nla_put_u64_64bit(msg, NL80211_STA_INFO_ ## attr, \ 4629 nla_put_u64_64bit(msg, NL80211_STA_INFO_ ## attr, \
4630 sinfo->memb, NL80211_STA_INFO_PAD)) \ 4630 sinfo->memb, NL80211_STA_INFO_PAD)) \
4631 goto nla_put_failure; \ 4631 goto nla_put_failure; \
@@ -4634,14 +4634,14 @@ static int nl80211_send_station(struct sk_buff *msg, u32 cmd, u32 portid,
4634 PUT_SINFO(CONNECTED_TIME, connected_time, u32); 4634 PUT_SINFO(CONNECTED_TIME, connected_time, u32);
4635 PUT_SINFO(INACTIVE_TIME, inactive_time, u32); 4635 PUT_SINFO(INACTIVE_TIME, inactive_time, u32);
4636 4636
4637 if (sinfo->filled & (BIT(NL80211_STA_INFO_RX_BYTES) | 4637 if (sinfo->filled & (BIT_ULL(NL80211_STA_INFO_RX_BYTES) |
4638 BIT(NL80211_STA_INFO_RX_BYTES64)) && 4638 BIT_ULL(NL80211_STA_INFO_RX_BYTES64)) &&
4639 nla_put_u32(msg, NL80211_STA_INFO_RX_BYTES, 4639 nla_put_u32(msg, NL80211_STA_INFO_RX_BYTES,
4640 (u32)sinfo->rx_bytes)) 4640 (u32)sinfo->rx_bytes))
4641 goto nla_put_failure; 4641 goto nla_put_failure;
4642 4642
4643 if (sinfo->filled & (BIT(NL80211_STA_INFO_TX_BYTES) | 4643 if (sinfo->filled & (BIT_ULL(NL80211_STA_INFO_TX_BYTES) |
4644 BIT(NL80211_STA_INFO_TX_BYTES64)) && 4644 BIT_ULL(NL80211_STA_INFO_TX_BYTES64)) &&
4645 nla_put_u32(msg, NL80211_STA_INFO_TX_BYTES, 4645 nla_put_u32(msg, NL80211_STA_INFO_TX_BYTES,
4646 (u32)sinfo->tx_bytes)) 4646 (u32)sinfo->tx_bytes))
4647 goto nla_put_failure; 4647 goto nla_put_failure;
@@ -4661,24 +4661,24 @@ static int nl80211_send_station(struct sk_buff *msg, u32 cmd, u32 portid,
4661 default: 4661 default:
4662 break; 4662 break;
4663 } 4663 }
4664 if (sinfo->filled & BIT(NL80211_STA_INFO_CHAIN_SIGNAL)) { 4664 if (sinfo->filled & BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL)) {
4665 if (!nl80211_put_signal(msg, sinfo->chains, 4665 if (!nl80211_put_signal(msg, sinfo->chains,
4666 sinfo->chain_signal, 4666 sinfo->chain_signal,
4667 NL80211_STA_INFO_CHAIN_SIGNAL)) 4667 NL80211_STA_INFO_CHAIN_SIGNAL))
4668 goto nla_put_failure; 4668 goto nla_put_failure;
4669 } 4669 }
4670 if (sinfo->filled & BIT(NL80211_STA_INFO_CHAIN_SIGNAL_AVG)) { 4670 if (sinfo->filled & BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL_AVG)) {
4671 if (!nl80211_put_signal(msg, sinfo->chains, 4671 if (!nl80211_put_signal(msg, sinfo->chains,
4672 sinfo->chain_signal_avg, 4672 sinfo->chain_signal_avg,
4673 NL80211_STA_INFO_CHAIN_SIGNAL_AVG)) 4673 NL80211_STA_INFO_CHAIN_SIGNAL_AVG))
4674 goto nla_put_failure; 4674 goto nla_put_failure;
4675 } 4675 }
4676 if (sinfo->filled & BIT(NL80211_STA_INFO_TX_BITRATE)) { 4676 if (sinfo->filled & BIT_ULL(NL80211_STA_INFO_TX_BITRATE)) {
4677 if (!nl80211_put_sta_rate(msg, &sinfo->txrate, 4677 if (!nl80211_put_sta_rate(msg, &sinfo->txrate,
4678 NL80211_STA_INFO_TX_BITRATE)) 4678 NL80211_STA_INFO_TX_BITRATE))
4679 goto nla_put_failure; 4679 goto nla_put_failure;
4680 } 4680 }
4681 if (sinfo->filled & BIT(NL80211_STA_INFO_RX_BITRATE)) { 4681 if (sinfo->filled & BIT_ULL(NL80211_STA_INFO_RX_BITRATE)) {
4682 if (!nl80211_put_sta_rate(msg, &sinfo->rxrate, 4682 if (!nl80211_put_sta_rate(msg, &sinfo->rxrate,
4683 NL80211_STA_INFO_RX_BITRATE)) 4683 NL80211_STA_INFO_RX_BITRATE))
4684 goto nla_put_failure; 4684 goto nla_put_failure;
@@ -4694,7 +4694,7 @@ static int nl80211_send_station(struct sk_buff *msg, u32 cmd, u32 portid,
4694 PUT_SINFO(PEER_PM, peer_pm, u32); 4694 PUT_SINFO(PEER_PM, peer_pm, u32);
4695 PUT_SINFO(NONPEER_PM, nonpeer_pm, u32); 4695 PUT_SINFO(NONPEER_PM, nonpeer_pm, u32);
4696 4696
4697 if (sinfo->filled & BIT(NL80211_STA_INFO_BSS_PARAM)) { 4697 if (sinfo->filled & BIT_ULL(NL80211_STA_INFO_BSS_PARAM)) {
4698 bss_param = nla_nest_start(msg, NL80211_STA_INFO_BSS_PARAM); 4698 bss_param = nla_nest_start(msg, NL80211_STA_INFO_BSS_PARAM);
4699 if (!bss_param) 4699 if (!bss_param)
4700 goto nla_put_failure; 4700 goto nla_put_failure;
@@ -4713,7 +4713,7 @@ static int nl80211_send_station(struct sk_buff *msg, u32 cmd, u32 portid,
4713 4713
4714 nla_nest_end(msg, bss_param); 4714 nla_nest_end(msg, bss_param);
4715 } 4715 }
4716 if ((sinfo->filled & BIT(NL80211_STA_INFO_STA_FLAGS)) && 4716 if ((sinfo->filled & BIT_ULL(NL80211_STA_INFO_STA_FLAGS)) &&
4717 nla_put(msg, NL80211_STA_INFO_STA_FLAGS, 4717 nla_put(msg, NL80211_STA_INFO_STA_FLAGS,
4718 sizeof(struct nl80211_sta_flag_update), 4718 sizeof(struct nl80211_sta_flag_update),
4719 &sinfo->sta_flags)) 4719 &sinfo->sta_flags))
@@ -10266,7 +10266,7 @@ static int cfg80211_cqm_rssi_update(struct cfg80211_registered_device *rdev,
10266 if (err) 10266 if (err)
10267 return err; 10267 return err;
10268 10268
10269 if (sinfo.filled & BIT(NL80211_STA_INFO_BEACON_SIGNAL_AVG)) 10269 if (sinfo.filled & BIT_ULL(NL80211_STA_INFO_BEACON_SIGNAL_AVG))
10270 wdev->cqm_config->last_rssi_event_value = 10270 wdev->cqm_config->last_rssi_event_value =
10271 (s8) sinfo.rx_beacon_signal_avg; 10271 (s8) sinfo.rx_beacon_signal_avg;
10272 } 10272 }
diff --git a/net/wireless/wext-compat.c b/net/wireless/wext-compat.c
index 05186a47878f..167f7025ac98 100644
--- a/net/wireless/wext-compat.c
+++ b/net/wireless/wext-compat.c
@@ -1278,7 +1278,7 @@ static int cfg80211_wext_giwrate(struct net_device *dev,
1278 if (err) 1278 if (err)
1279 return err; 1279 return err;
1280 1280
1281 if (!(sinfo.filled & BIT(NL80211_STA_INFO_TX_BITRATE))) 1281 if (!(sinfo.filled & BIT_ULL(NL80211_STA_INFO_TX_BITRATE)))
1282 return -EOPNOTSUPP; 1282 return -EOPNOTSUPP;
1283 1283
1284 rate->value = 100000 * cfg80211_calculate_bitrate(&sinfo.txrate); 1284 rate->value = 100000 * cfg80211_calculate_bitrate(&sinfo.txrate);
@@ -1320,7 +1320,7 @@ static struct iw_statistics *cfg80211_wireless_stats(struct net_device *dev)
1320 1320
1321 switch (rdev->wiphy.signal_type) { 1321 switch (rdev->wiphy.signal_type) {
1322 case CFG80211_SIGNAL_TYPE_MBM: 1322 case CFG80211_SIGNAL_TYPE_MBM:
1323 if (sinfo.filled & BIT(NL80211_STA_INFO_SIGNAL)) { 1323 if (sinfo.filled & BIT_ULL(NL80211_STA_INFO_SIGNAL)) {
1324 int sig = sinfo.signal; 1324 int sig = sinfo.signal;
1325 wstats.qual.updated |= IW_QUAL_LEVEL_UPDATED; 1325 wstats.qual.updated |= IW_QUAL_LEVEL_UPDATED;
1326 wstats.qual.updated |= IW_QUAL_QUAL_UPDATED; 1326 wstats.qual.updated |= IW_QUAL_QUAL_UPDATED;
@@ -1334,7 +1334,7 @@ static struct iw_statistics *cfg80211_wireless_stats(struct net_device *dev)
1334 break; 1334 break;
1335 } 1335 }
1336 case CFG80211_SIGNAL_TYPE_UNSPEC: 1336 case CFG80211_SIGNAL_TYPE_UNSPEC:
1337 if (sinfo.filled & BIT(NL80211_STA_INFO_SIGNAL)) { 1337 if (sinfo.filled & BIT_ULL(NL80211_STA_INFO_SIGNAL)) {
1338 wstats.qual.updated |= IW_QUAL_LEVEL_UPDATED; 1338 wstats.qual.updated |= IW_QUAL_LEVEL_UPDATED;
1339 wstats.qual.updated |= IW_QUAL_QUAL_UPDATED; 1339 wstats.qual.updated |= IW_QUAL_QUAL_UPDATED;
1340 wstats.qual.level = sinfo.signal; 1340 wstats.qual.level = sinfo.signal;
@@ -1347,9 +1347,9 @@ static struct iw_statistics *cfg80211_wireless_stats(struct net_device *dev)
1347 } 1347 }
1348 1348
1349 wstats.qual.updated |= IW_QUAL_NOISE_INVALID; 1349 wstats.qual.updated |= IW_QUAL_NOISE_INVALID;
1350 if (sinfo.filled & BIT(NL80211_STA_INFO_RX_DROP_MISC)) 1350 if (sinfo.filled & BIT_ULL(NL80211_STA_INFO_RX_DROP_MISC))
1351 wstats.discard.misc = sinfo.rx_dropped_misc; 1351 wstats.discard.misc = sinfo.rx_dropped_misc;
1352 if (sinfo.filled & BIT(NL80211_STA_INFO_TX_FAILED)) 1352 if (sinfo.filled & BIT_ULL(NL80211_STA_INFO_TX_FAILED))
1353 wstats.discard.retries = sinfo.tx_failed; 1353 wstats.discard.retries = sinfo.tx_failed;
1354 1354
1355 return &wstats; 1355 return &wstats;