]> git.proxmox.com Git - mirror_ubuntu-focal-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)
committerStefan Bader <stefan.bader@canonical.com>
Thu, 14 Apr 2022 09:32:07 +0000 (11:32 +0200)
commitc74ca134a1f89db24c4fabf98530cbcd8010d299
treeaf2ae13def776b9edbfaa89dbe02b962e7c5f181
parentfcbbf3c7cd9bc862aef7a8fd86daf0f0a5025868
eeprom: ee1004: limit i2c reads to I2C_SMBUS_BLOCK_MAX

BugLink: https://bugs.launchpad.net/bugs/1966118
commit c0689e46be23160d925dca95dfc411f1a0462708 upstream.

Commit effa453168a7 ("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: effa453168a7 ("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>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/misc/eeprom/ee1004.c