Patch "i2c: core: check returned size of emulated smbus block read" has been added to the 5.7-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: core: check returned size of emulated smbus block read

to the 5.7-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-core-check-returned-size-of-emulated-smbus-block.patch
and it can be found in the queue-5.7 subdirectory.

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



commit 9fe0919cd84250b2b88c6c960151e070360b02dd
Author: Mans Rullgard <mans@xxxxxxxxx>
Date:   Sat Jun 13 11:41:09 2020 +0100

    i2c: core: check returned size of emulated smbus block read
    
    [ Upstream commit 40e05200593af06633f64ab0effff052eee6f076 ]
    
    If the i2c bus driver ignores the I2C_M_RECV_LEN flag (as some of
    them do), it is possible for an I2C_SMBUS_BLOCK_DATA read issued
    on some random device to return an arbitrary value in the first
    byte (and nothing else).  When this happens, i2c_smbus_xfer_emulated()
    will happily write past the end of the supplied data buffer, thus
    causing Bad Things to happen.  To prevent this, check the size
    before copying the data block and return an error if it is too large.
    
    Fixes: 209d27c3b167 ("i2c: Emulate SMBus block read over I2C")
    Signed-off-by: Mans Rullgard <mans@xxxxxxxxx>
    [wsa: use better errno]
    Signed-off-by: Wolfram Sang <wsa@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/i2c/i2c-core-smbus.c b/drivers/i2c/i2c-core-smbus.c
index b34d2ff069318..bbb70a8a411e3 100644
--- a/drivers/i2c/i2c-core-smbus.c
+++ b/drivers/i2c/i2c-core-smbus.c
@@ -495,6 +495,13 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter *adapter, u16 addr,
 			break;
 		case I2C_SMBUS_BLOCK_DATA:
 		case I2C_SMBUS_BLOCK_PROC_CALL:
+			if (msg[1].buf[0] > I2C_SMBUS_BLOCK_MAX) {
+				dev_err(&adapter->dev,
+					"Invalid block size returned: %d\n",
+					msg[1].buf[0]);
+				status = -EPROTO;
+				goto cleanup;
+			}
 			for (i = 0; i < msg[1].buf[0] + 1; i++)
 				data->block[i] = msg[1].buf[i];
 			break;



[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