Patch "i2c: mlxbf: prevent stack overflow in mlxbf_i2c_smbus_start_transaction()" has been added to the 5.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

    i2c: mlxbf: prevent stack overflow in mlxbf_i2c_smbus_start_transaction()

to the 5.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:
     i2c-mlxbf-prevent-stack-overflow-in-mlxbf_i2c_smbus_.patch
and it can be found in the queue-5.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 e69ca83dcf000f6f8247cdfba2bf4e500355f53e
Author: Asmaa Mnebhi <asmaa@xxxxxxxxxx>
Date:   Thu Sep 8 13:35:39 2022 -0400

    i2c: mlxbf: prevent stack overflow in mlxbf_i2c_smbus_start_transaction()
    
    [ Upstream commit de24aceb07d426b6f1c59f33889d6a964770547b ]
    
    memcpy() is called in a loop while 'operation->length' upper bound
    is not checked and 'data_idx' also increments.
    
    Fixes: b5b5b32081cd206b ("i2c: mlxbf: I2C SMBus driver for Mellanox BlueField SoC")
    Reviewed-by: Khalil Blaiech <kblaiech@xxxxxxxxxx>
    Signed-off-by: Asmaa Mnebhi <asmaa@xxxxxxxxxx>
    Signed-off-by: Wolfram Sang <wsa@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/i2c/busses/i2c-mlxbf.c b/drivers/i2c/busses/i2c-mlxbf.c
index 612736906440..ac93c0ccf53c 100644
--- a/drivers/i2c/busses/i2c-mlxbf.c
+++ b/drivers/i2c/busses/i2c-mlxbf.c
@@ -738,6 +738,9 @@ mlxbf_i2c_smbus_start_transaction(struct mlxbf_i2c_priv *priv,
 		if (flags & MLXBF_I2C_F_WRITE) {
 			write_en = 1;
 			write_len += operation->length;
+			if (data_idx + operation->length >
+					MLXBF_I2C_MASTER_DATA_DESC_SIZE)
+				return -ENOBUFS;
 			memcpy(data_desc + data_idx,
 			       operation->buffer, operation->length);
 			data_idx += operation->length;



[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