Patch "net/mlx5e: Correct snprintf truncation handling for fw_version buffer" has been added to the 6.1-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/mlx5e: Correct snprintf truncation handling for fw_version buffer

to the 6.1-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-mlx5e-correct-snprintf-truncation-handling-for-f.patch
and it can be found in the queue-6.1 subdirectory.

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



commit 0cb9b7db6ec63a8876d9ff6840827cf88981b910
Author: Rahul Rameshbabu <rrameshbabu@xxxxxxxxxx>
Date:   Tue Nov 21 15:00:21 2023 -0800

    net/mlx5e: Correct snprintf truncation handling for fw_version buffer
    
    [ Upstream commit ad436b9c1270c40554e274f067f1b78fcc06a004 ]
    
    snprintf returns the length of the formatted string, excluding the trailing
    null, without accounting for truncation. This means that is the return
    value is greater than or equal to the size parameter, the fw_version string
    was truncated.
    
    Reported-by: David Laight <David.Laight@xxxxxxxxxx>
    Closes: https://lore.kernel.org/netdev/81cae734ee1b4cde9b380a9a31006c1a@xxxxxxxxxxxxxxxx/
    Link: https://docs.kernel.org/core-api/kernel-api.html#c.snprintf
    Fixes: 41e63c2baa11 ("net/mlx5e: Check return value of snprintf writing to fw_version buffer")
    Signed-off-by: Rahul Rameshbabu <rrameshbabu@xxxxxxxxxx>
    Reviewed-by: Simon Horman <horms@xxxxxxxxxx>
    Signed-off-by: Saeed Mahameed <saeedm@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
index eeba91d9c5211..ceeb23f478e15 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
@@ -49,7 +49,7 @@ void mlx5e_ethtool_get_drvinfo(struct mlx5e_priv *priv,
 	count = snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version),
 			 "%d.%d.%04d (%.16s)", fw_rev_maj(mdev),
 			 fw_rev_min(mdev), fw_rev_sub(mdev), mdev->board_id);
-	if (count == sizeof(drvinfo->fw_version))
+	if (count >= sizeof(drvinfo->fw_version))
 		snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version),
 			 "%d.%d.%04d", fw_rev_maj(mdev),
 			 fw_rev_min(mdev), fw_rev_sub(mdev));




[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