Input: clamp SMBus block reads to the caller's buffer
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v2 Latest2 patches 0 repliesNew
- v12 patches 2 repliesSuperseded
Patches in v2 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | Input: rmi4 - clamp SMBus block reads to the requested lengthdrivers/ | +16 | 0 replies | |
| 2/2 | Input: cyapa - clamp SMBus block reads to the caller's buffer sizedrivers/ | +20 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.
Cover letter [PATCH v2 0/2] Input: clamp SMBus block reads to the caller's buffer
i2c_smbus_read_block_data() has no length parameter: it copies the device-reported byte count (clamped to I2C_SMBUS_BLOCK_MAX by the core) into the caller's buffer, so callers must pass a full-size buffer. An audit of all call sites found two input drivers passing smaller stack buffers:
- rmi4: rmi_read_pdt_entry() reads PDT entries into a 6-byte stack buffer during PDT scanning at probe time; a device reporting a count of 32 overruns it by 26 bytes.
- cyapa: cyapa_gen3_irq_handler() reads into a 27-byte struct cyapa_reg_data on every touch interrupt; a count of 32 overruns it by 5 bytes, in interrupt context.
In both cases the contents are controlled by the device. Bounce the reads through a full-size buffer and clamp the copy to the requested length.
Found by static analysis (audit of i2c_smbus_read_block_data() callers).
---
v2: cyapa: also fail short reads with -EIO (Sashiko AI review of v1):
the "ret > 0 ? len : ret" convention masked them, so callers' full-read checks passed with uninitialized stack contents in the unread tail (and leaked it via the product_id sysfs attribute).
rmi4 is unchanged; its read path pre-zeroes the caller's buffer.
v1: https://lore.kernel.org/linux-input/[email protected]/
---
Chengyu Liu (2):
Input: rmi4 - clamp SMBus block reads to the requested length
Input: cyapa - clamp SMBus block reads to the caller's buffer size
drivers/input/mouse/cyapa_gen3.c | 22 ++++++++++++++++++++-- drivers/input/rmi4/rmi_smbus.c | 17 ++++++++++++++++- 2 files changed, 36 insertions(+), 3 deletions(-)
Signature · 1 line
2.25.1