]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
mac80211: ethtool: avoid 32 bit multiplication overflow
authorColin Ian King <colin.king@canonical.com>
Tue, 8 May 2018 12:57:32 +0000 (13:57 +0100)
committerJohannes Berg <johannes.berg@intel.com>
Tue, 8 May 2018 13:02:03 +0000 (15:02 +0200)
The multiplication of 100000 * cfg80211_calculate_bitrate() is a 32 bit
operation and can overflow if cfg80211_calculate_bitrate is greater
than 42949. Although I don't believe this is occurring at present, it
would be safer to avoid the potential overflow by making the constant
100000 an ULL to ensure a 64 multiplication occurs.

Detected by CoverityScan, CID#1468643 ("Unintentional integer overflow")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/ethtool.c

index 1afeff94af8ba37d130ef3cfd8c4acb0a042adea..09210aa8ea9ad7ed17d4f22dd5b75a8cca2b8a0e 100644 (file)
@@ -121,11 +121,11 @@ static void ieee80211_get_stats(struct net_device *dev,
 
 
                if (sinfo->filled & BIT(NL80211_STA_INFO_TX_BITRATE))
-                       data[i] = 100000 *
+                       data[i] = 100000ULL *
                                cfg80211_calculate_bitrate(&sinfo->txrate);
                i++;
                if (sinfo->filled & BIT(NL80211_STA_INFO_RX_BITRATE))
-                       data[i] = 100000 *
+                       data[i] = 100000ULL *
                                cfg80211_calculate_bitrate(&sinfo->rxrate);
                i++;