Patch "net: Fix unwanted sign extension in netdev_stats_to_stats64()" has been added to the 4.19-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    net: Fix unwanted sign extension in netdev_stats_to_stats64()

to the 4.19-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     net-fix-unwanted-sign-extension-in-netdev_stats_to_s.patch
and it can be found in the queue-4.19 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit adc3a55bb14544428f4a5eedcedb39d200f58685
Author: Felix Riemann <felix.riemann@xxxxxx>
Date:   Fri Feb 10 13:36:44 2023 +0100

    net: Fix unwanted sign extension in netdev_stats_to_stats64()
    
    [ Upstream commit 9b55d3f0a69af649c62cbc2633e6d695bb3cc583 ]
    
    When converting net_device_stats to rtnl_link_stats64 sign extension
    is triggered on ILP32 machines as 6c1c509778 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: 6c1c5097781f ("net: add atomic_long_t to net_device_stats fields")
    Signed-off-by: Felix Riemann <felix.riemann@xxxxxx>
    Reviewed-by: Eric Dumazet <edumazet@xxxxxxxxxx>
    Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/net/core/dev.c b/net/core/dev.c
index 3bf40c288c032..0f9214fb36e01 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -9041,7 +9041,7 @@ void netdev_stats_to_stats64(struct rtnl_link_stats64 *stats64,
 
 	BUILD_BUG_ON(n > sizeof(*stats64) / sizeof(u64));
 	for (i = 0; i < n; i++)
-		dst[i] = atomic_long_read(&src[i]);
+		dst[i] = (unsigned long)atomic_long_read(&src[i]);
 	/* zero out counters that only exist in rtnl_link_stats64 */
 	memset((char *)stats64 + n * sizeof(u64), 0,
 	       sizeof(*stats64) - n * sizeof(u64));



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux