From: Chengyu Liu <lui2012qwq@gmail.com>
To: dmitry.torokhov@gmail.com
Cc: linux-input@vger.kernel.org, Chengyu Liu <lui2012qwq@gmail.com>
Subject: [PATCH 0/2] Input: clamp SMBus block reads to the caller's buffer
Date: Tue, 3 Nov 2026 21:11:25 +0800 [thread overview]
Message-ID: <20261103131127.1585884-1-lui2012qwq@gmail.com> (raw)
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).
Signed-off-by: Chengyu Liu <lui2012qwq@gmail.com>
---
Chengyu Liu (2):
Input: rmi4 - clamp SMBus block reads to the requested length
Input: cyapa - clamp SMBus block reads to the caller's buffer
drivers/input/mouse/cyapa_gen3.c | 14 ++++++++++++--
drivers/input/rmi4/rmi_smbus.c | 17 ++++++++++++++++-
2 files changed, 28 insertions(+), 3 deletions(-)
--
2.25.1
next reply other threads:[~2026-11-03 13:11 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-03 13:11 Chengyu Liu [this message]
2026-11-03 13:11 ` [PATCH 1/2] Input: rmi4 - clamp SMBus block reads to the requested length Chengyu Liu
2026-11-03 13:11 ` [PATCH 2/2] Input: cyapa - clamp SMBus block reads to the caller's buffer Chengyu Liu
2026-11-03 13:22 ` sashiko-bot
2026-11-03 14:10 ` cy l
2026-11-03 18:48 ` [PATCH 0/2] Input: " Dmitry Torokhov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261103131127.1585884-1-lui2012qwq@gmail.com \
--to=lui2012qwq@gmail.com \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.