Skip to content

Commit 06f683c

Browse files
committed
i2c: mlxbf: prevent stack overflow in mlxbf_i2c_smbus_start_transaction()
jira LE-1907 cve CVE-2022-48632 Rebuild_History Non-Buildable kernel-4.18.0-553.16.1.el8_10 commit-author Asmaa Mnebhi <[email protected]> commit de24ace memcpy() is called in a loop while 'operation->length' upper bound is not checked and 'data_idx' also increments. Fixes: b5b5b32 ("i2c: mlxbf: I2C SMBus driver for Mellanox BlueField SoC") Reviewed-by: Khalil Blaiech <[email protected]> Signed-off-by: Asmaa Mnebhi <[email protected]> Signed-off-by: Wolfram Sang <[email protected]> (cherry picked from commit de24ace) Signed-off-by: Jonathan Maple <[email protected]>
1 parent 3b5795c commit 06f683c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/i2c/busses/i2c-mlxbf.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,9 @@ mlxbf_i2c_smbus_start_transaction(struct mlxbf_i2c_priv *priv,
744744
if (flags & MLXBF_I2C_F_WRITE) {
745745
write_en = 1;
746746
write_len += operation->length;
747+
if (data_idx + operation->length >
748+
MLXBF_I2C_MASTER_DATA_DESC_SIZE)
749+
return -ENOBUFS;
747750
memcpy(data_desc + data_idx,
748751
operation->buffer, operation->length);
749752
data_idx += operation->length;

0 commit comments

Comments
 (0)