From: Eric Dumazet Date: Tue, 27 Jun 2017 14:02:20 +0000 (-0700) Subject: net: prevent sign extension in dev_get_stats() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=4ef41964ac05a4e3c34173f40aa6e2ecbb978a16;p=GitHub%2Fmt8127%2Fandroid_kernel_alcatel_ttab.git net: prevent sign extension in dev_get_stats() commit 6f64ec74515925cced6df4571638b5a099a49aae upstream. Similar to the fix provided by Dominik Heidler in commit 9b3dc0a17d73 ("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: caf586e5f23ce ("net: add a core netdev->rx_dropped counter") Fixes: 015f0688f57ca ("net: net: add a core netdev->tx_dropped counter") Fixes: 6e7333d315a76 ("net: add rx_nohandler stat counter") Signed-off-by: Eric Dumazet Cc: Jarod Wilson Signed-off-by: David S. Miller Signed-off-by: Willy Tarreau --- diff --git a/net/core/dev.c b/net/core/dev.c index c8842036508f..d69d8ec11383 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -5643,7 +5643,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev, } else { 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); return storage; } EXPORT_SYMBOL(dev_get_stats);