]> git.baikalelectronics.ru Git - kernel.git/commit
eeprom: ee1004: limit i2c reads to I2C_SMBUS_BLOCK_MAX
authorJonas Malaco <jonas@protocubo.io>
Thu, 3 Feb 2022 16:49:52 +0000 (13:49 -0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 4 Feb 2022 15:27:44 +0000 (16:27 +0100)
commit5eff96c49b6917a3d39d8f90034c7c37566f77bb
tree2246752f24ddeb0d5b50d8f7de626259dfdd8906
parent63beabaebd764a2bfaa866a156c582f94ac36399
eeprom: ee1004: limit i2c reads to I2C_SMBUS_BLOCK_MAX

Commit c1e679168fd4 ("i2c: i801: Don't silently correct invalid transfer
size") revealed that ee1004_eeprom_read() did not properly limit how
many bytes to read at once.

In particular, i2c_smbus_read_i2c_block_data_or_emulated() takes the
length to read as an u8.  If count == 256 after taking into account the
offset and page boundary, the cast to u8 overflows.  And this is common
when user space tries to read the entire EEPROM at once.

To fix it, limit each read to I2C_SMBUS_BLOCK_MAX (32) bytes, already
the maximum length i2c_smbus_read_i2c_block_data_or_emulated() allows.

Fixes: c1e679168fd4 ("i2c: i801: Don't silently correct invalid transfer size")
Cc: stable@vger.kernel.org
Reviewed-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Jonas Malaco <jonas@protocubo.io>
Link: https://lore.kernel.org/r/20220203165024.47767-1-jonas@protocubo.io
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/eeprom/ee1004.c