Skip to content

Commit 690b254

Browse files
Dan Carpentertorvalds
authored andcommitted
i2c: ismt: prevent memory corruption in ismt_access()
The "data->block[0]" variable comes from the user and is a number between 0-255. It needs to be capped to prevent writing beyond the end of dma_buffer[]. Fixes: 5e9a97b ("i2c: ismt: Adding support for I2C_SMBUS_BLOCK_PROC_CALL") Reported-and-tested-by: Zheyu Ma <zheyuma97@gmail.com> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent d1dc877 commit 690b254

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/i2c/busses/i2c-ismt.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,9 @@ static int ismt_access(struct i2c_adapter *adap, u16 addr,
528528

529529
case I2C_SMBUS_BLOCK_PROC_CALL:
530530
dev_dbg(dev, "I2C_SMBUS_BLOCK_PROC_CALL\n");
531+
if (data->block[0] > I2C_SMBUS_BLOCK_MAX)
532+
return -EINVAL;
533+
531534
dma_size = I2C_SMBUS_BLOCK_MAX;
532535
desc->tgtaddr_rw = ISMT_DESC_ADDR_RW(addr, 1);
533536
desc->wr_len_cmd = data->block[0] + 1;

0 commit comments

Comments
 (0)