* [PATCH] i2c: i801: Fix out-of-bounds bug in i801_block_transaction _byte_by_byte
@ 2025-06-15 23:33 Alex Guo
2025-06-16 8:48 ` Jean Delvare
0 siblings, 1 reply; 2+ messages in thread
From: Alex Guo @ 2025-06-15 23:33 UTC (permalink / raw)
To: jdelvare; +Cc: alexguo1023, andi.shyti, linux-i2c, linux-kernel
The data->block[0] variable comes from user. Without proper check,
the variable may be very large to cause an out-of-bounds bug.
Fix this bug by checking the value of data->block[0] first.
Similar commit:
1. commit 39244cc7548 ("i2c: ismt: Fix an out-of-bounds bug in
ismt_access()")
2. commit 92fbb6d1296 ("i2c: xgene-slimpro: Fix out-of-bounds
bug in xgene_slimpro_i2c_xfer()")
Signed-off-by: Alex Guo <alexguo1023@gmail.com>
---
drivers/i2c/busses/i2c-i801.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index 7503418be39a..aed4473fb9ba 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -678,6 +678,8 @@ static int i801_block_transaction_byte_by_byte(struct i801_priv *priv,
return -EOPNOTSUPP;
len = data->block[0];
+ if (len < 1 || len > I2C_SMBUS_BLOCK_MAX)
+ return -EINVAL;
if (read_write == I2C_SMBUS_WRITE) {
iowrite8(len, SMBHSTDAT0(priv));
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] i2c: i801: Fix out-of-bounds bug in i801_block_transaction _byte_by_byte
2025-06-15 23:33 [PATCH] i2c: i801: Fix out-of-bounds bug in i801_block_transaction _byte_by_byte Alex Guo
@ 2025-06-16 8:48 ` Jean Delvare
0 siblings, 0 replies; 2+ messages in thread
From: Jean Delvare @ 2025-06-16 8:48 UTC (permalink / raw)
To: Alex Guo; +Cc: andi.shyti, linux-i2c, linux-kernel
Hi Alex,
On Sun, 15 Jun 2025 19:33:06 -0400, Alex Guo wrote:
> The data->block[0] variable comes from user. Without proper check,
> the variable may be very large to cause an out-of-bounds bug.
>
> Fix this bug by checking the value of data->block[0] first.
The same check is already present in i801_smbus_block_transaction() and
i801_i2c_block_transaction(), which are the only 2 functions calling
i801_block_transaction_byte_by_byte(). So the out-of-bounds bug you
describe does not exist.
--
Jean Delvare
SUSE L3 Support
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-06-16 8:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-15 23:33 [PATCH] i2c: i801: Fix out-of-bounds bug in i801_block_transaction _byte_by_byte Alex Guo
2025-06-16 8:48 ` Jean Delvare
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).