From: sashiko-bot@kernel.org
To: "Pengpeng Hou" <pengpeng@iscas.ac.cn>
Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org
Subject: Re: [PATCH] Input: hynitron_cstxxx - validate touch count against buffer
Date: Tue, 30 Jun 2026 07:45:36 +0000 [thread overview]
Message-ID: <20260630074537.03B311F000E9@smtp.kernel.org> (raw)
In-Reply-To: <2026063009041899.4-ccfa108-0047-Input-hynitron_cstxxx---val-pengpeng@iscas.ac.cn>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The driver passes stack-allocated memory to `i2c_transfer()` and `i2c_master_send()`, which can cause memory corruption or system crashes if the underlying I2C controller uses DMA.
--
commit c00eb5cc820dacf72d27095570836d29b4df9d2d
Author: Pengpeng Hou <pengpeng@iscas.ac.cn>
Input: hynitron_cstxxx - validate touch count against buffer
Bounds the device-reported touch count against the chip limit and buffer
layout before parsing touch slots.
> diff --git a/drivers/input/touchscreen/hynitron_cstxxx.c b/drivers/input/touchscreen/hynitron_cstxxx.c
> index 1d8ca90dcda69..6644272bc72a4 100644
> --- a/drivers/input/touchscreen/hynitron_cstxxx.c
> +++ b/drivers/input/touchscreen/hynitron_cstxxx.c
> @@ -313,6 +313,12 @@ static void cst3xx_touch_report(struct i2c_client *client)
> return;
>
> touch_cnt = buf[5] & CST3XX_TOUCH_COUNT_MASK;
[Severity: High]
This isn't a bug introduced by this patch, but is it safe to use
stack-allocated memory for I2C transfers?
Looking at cst3xx_touch_report(), buf is allocated on the stack and passed
down to cst3xx_i2c_read_register():
drivers/input/touchscreen/hynitron_cstxxx.c:cst3xx_touch_report() {
...
u8 buf[28];
...
err = cst3xx_i2c_read_register(client, CST3XX_TOUCH_DATA_PART_REG,
buf, 28);
...
}
The cst3xx_i2c_read_register() function also appears to allocate its register
address buffer on the stack:
drivers/input/touchscreen/hynitron_cstxxx.c:cst3xx_i2c_read_register() {
...
__le16 buf = cpu_to_le16(reg);
...
.buf = (u8 *)&buf,
...
}
If the underlying I2C adapter driver uses DMA to perform the transfer, mapping
stack memory for DMA can cause cache coherency issues, memory corruption, or
kernel panics, particularly when CONFIG_VMAP_STACK is enabled.
> + if (touch_cnt > ts_data->chip->max_touch_num ||
> + (touch_cnt > 1 && touch_cnt * 5 + 2 >= sizeof(buf))) {
> + dev_err(&client->dev, "cst3xx touch read failure\n");
> + return;
> + }
> +
> /*
> * Check the check bit of the last touch slot. The check bit is
> * always present after touch point 1 for valid data, and then
--
Sashiko AI review · https://sashiko.dev/#/patchset/2026063009041899.4-ccfa108-0047-Input-hynitron_cstxxx---val-pengpeng@iscas.ac.cn?part=1
prev parent reply other threads:[~2026-06-30 7:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-30 7:30 [PATCH] Input: hynitron_cstxxx - validate touch count against buffer Pengpeng Hou
2026-06-30 7:45 ` sashiko-bot [this message]
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=20260630074537.03B311F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=pengpeng@iscas.ac.cn \
--cc=sashiko-reviews@lists.linux.dev \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox