Commit 6956b55d authored by Eric Dumazet's avatar Eric Dumazet Committed by Ben Hutchings

net: prevent sign extension in dev_get_stats()

commit 6f64ec74 upstream.

Similar to the fix provided by Dominik Heidler in commit
9b3dc0a1 ("l2tp: cast l2tp traffic counter to unsigned")
we need to take care of 32bit kernels in dev_get_stats().

When using atomic_long_read(), we add a 'long' to u64 and
might misinterpret high order bit, unless we cast to unsigned.

Fixes: caf586e5 ("net: add a core netdev->rx_dropped counter")
Fixes: 015f0688 ("net: net: add a core netdev->tx_dropped counter")
Fixes: 6e7333d3 ("net: add rx_nohandler stat counter")
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Cc: Jarod Wilson <jarod@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
[bwh: Backported to 3.16: only {rx,tx}_dropped are updated here]
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent 58347335
...@@ -6509,8 +6509,8 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev, ...@@ -6509,8 +6509,8 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
} else { } else {
netdev_stats_to_stats64(storage, &dev->stats); netdev_stats_to_stats64(storage, &dev->stats);
} }
storage->rx_dropped += atomic_long_read(&dev->rx_dropped); storage->rx_dropped += (unsigned long)atomic_long_read(&dev->rx_dropped);
storage->tx_dropped += atomic_long_read(&dev->tx_dropped); storage->tx_dropped += (unsigned long)atomic_long_read(&dev->tx_dropped);
return storage; return storage;
} }
EXPORT_SYMBOL(dev_get_stats); EXPORT_SYMBOL(dev_get_stats);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment