Patch "alx: fix OOB-read compiler warning" has been added to the 5.10-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

    alx: fix OOB-read compiler warning

to the 5.10-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:
     alx-fix-oob-read-compiler-warning.patch
and it can be found in the queue-5.10 subdirectory.

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



commit b67e27aeb09a0da85fca6a1a4d2e27094253772d
Author: GONG, Ruiqi <gongruiqi1@xxxxxxxxxx>
Date:   Mon Aug 21 09:32:18 2023 +0800

    alx: fix OOB-read compiler warning
    
    [ Upstream commit 3a198c95c95da10ad844cbeade2fe40bdf14c411 ]
    
    The following message shows up when compiling with W=1:
    
    In function ‘fortify_memcpy_chk’,
        inlined from ‘alx_get_ethtool_stats’ at drivers/net/ethernet/atheros/alx/ethtool.c:297:2:
    ./include/linux/fortify-string.h:592:4: error: call to ‘__read_overflow2_field’
    declared with attribute warning: detected read beyond size of field (2nd parameter);
    maybe use struct_group()? [-Werror=attribute-warning]
      592 |    __read_overflow2_field(q_size_field, size);
          |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    In order to get alx stats altogether, alx_get_ethtool_stats() reads
    beyond hw->stats.rx_ok. Fix this warning by directly copying hw->stats,
    and refactor the unnecessarily complicated BUILD_BUG_ON btw.
    
    Signed-off-by: GONG, Ruiqi <gongruiqi1@xxxxxxxxxx>
    Reviewed-by: Simon Horman <horms@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20230821013218.1614265-1-gongruiqi@xxxxxxxxxxxxxxx
    Signed-off-by: Paolo Abeni <pabeni@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/net/ethernet/atheros/alx/ethtool.c b/drivers/net/ethernet/atheros/alx/ethtool.c
index 2f4eabf652e80..51e5aa2c74b34 100644
--- a/drivers/net/ethernet/atheros/alx/ethtool.c
+++ b/drivers/net/ethernet/atheros/alx/ethtool.c
@@ -281,9 +281,8 @@ static void alx_get_ethtool_stats(struct net_device *netdev,
 	spin_lock(&alx->stats_lock);
 
 	alx_update_hw_stats(hw);
-	BUILD_BUG_ON(sizeof(hw->stats) - offsetof(struct alx_hw_stats, rx_ok) <
-		     ALX_NUM_STATS * sizeof(u64));
-	memcpy(data, &hw->stats.rx_ok, ALX_NUM_STATS * sizeof(u64));
+	BUILD_BUG_ON(sizeof(hw->stats) != ALX_NUM_STATS * sizeof(u64));
+	memcpy(data, &hw->stats, sizeof(hw->stats));
 
 	spin_unlock(&alx->stats_lock);
 }



[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