net: Fix unwanted sign extension in netdev_stats_to_stats64()
stable inclusion from stable-v4.19.296 commit b17d81b94d24834d0ee038c6e216752f43b67cc9 category: bugfix bugzilla: https://gitee.com/src-openeuler/kernel/issues/I95ATV CVE: CVE-2023-52578 Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=b17d81b94d24834d0ee038c6e216752f43b67cc9 -------------------------------- [ Upstream commit 9b55d3f0 ] When converting net_device_stats to rtnl_link_stats64 sign extension is triggered on ILP32 machines as 6c1c5097 changed the previous "ulong -> u64" conversion to "long -> u64" by accessing the net_device_stats fields through a (signed) atomic_long_t. This causes for example the received bytes counter to jump to 16EiB after having received 2^31 bytes. Casting the atomic value to "unsigned long" beforehand converting it into u64 avoids this. Fixes: 6c1c5097 ("net: add atomic_long_t to net_device_stats fields") Signed-off-by:Felix Riemann <felix.riemann@sma.de> Reviewed-by:
Eric Dumazet <edumazet@google.com> Signed-off-by:
David S. Miller <davem@davemloft.net> Signed-off-by:
Sasha Levin <sashal@kernel.org> Signed-off-by:
Zhengchao Shao <shaozhengchao@huawei.com>
Loading
Please sign in to comment