[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <tencent_9443A8C45A37693763A6D7D3658367896405@qq.com>
Date: Tue, 20 Jan 2026 21:47:02 +0800
From: Edward Adam Davis <eadavis@...com>
To: syzbot+64ca69977b37604cd6d9@...kaller.appspotmail.com
Cc: bentiss@...nel.org,
jikos@...nel.org,
linux-i2c@...r.kernel.org,
linux-input@...r.kernel.org,
linux-kernel@...r.kernel.org,
michael.zaidman@...il.com,
syzkaller-bugs@...glegroups.com
Subject: [PATCH] i2c: add sanity check for input SMBus data length
The value passed to block[0] in the user-constructed data is too large,
exceeding the length that data for SMBus messages can accommodate. This
triggered the out-of-bounds access reported by syzbot [1].
Adding relevant data size checks in the smbus ioctl can prevent this
out-of-bounds access.
[1]
BUG: KASAN: stack-out-of-bounds in ft260_smbus_write+0x19b/0x2f0 drivers/hid/hid-ft260.c:486
Read of size 42 at addr ffffc90003427d81 by task syz.2.65/6119
Call Trace:
ft260_smbus_write+0x19b/0x2f0 drivers/hid/hid-ft260.c:486
ft260_smbus_xfer+0x22c/0x640 drivers/hid/hid-ft260.c:736
Reported-by: syzbot+64ca69977b37604cd6d9@...kaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=64ca69977b37604cd6d9
Signed-off-by: Edward Adam Davis <eadavis@...com>
---
drivers/i2c/i2c-dev.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
index e9577f920286..6725a49d6921 100644
--- a/drivers/i2c/i2c-dev.c
+++ b/drivers/i2c/i2c-dev.c
@@ -378,6 +378,14 @@ static noinline int i2cdev_ioctl_smbus(struct i2c_client *client,
(read_write == I2C_SMBUS_WRITE)) {
if (copy_from_user(&temp, data, datasize))
return -EFAULT;
+
+ if (temp.block[0] > datasize) {
+ dev_dbg(&client->adapter->dev,
+ "user input data size (%u) is too big "
+ "in ioctl I2C_SMBUS.\n",
+ temp.block[0]);
+ return -EINVAL;
+ }
}
if (size == I2C_SMBUS_I2C_BLOCK_BROKEN) {
/* Convert old I2C block commands to the new
--
2.43.0
Powered by blists - more mailing lists