From: sashiko-bot@kernel.org
To: "Chen Changcheng" <chenchangcheng@kylinos.cn>
Cc: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH 3/4] HID: picolcd: Use min() macro to simplify code
Date: Tue, 28 Jul 2026 03:06:34 +0000 [thread overview]
Message-ID: <20260728030635.1C5C51F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260728025750.48249-4-chenchangcheng@kylinos.cn>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Out-of-bounds read in `picolcd_debug_eeprom_read` leaking kernel heap memory to userspace.
--
--- Patch [3]: [PATCH 3/4] HID: picolcd: Use min() macro to simplify code ---
commit 1474980d788a9366218f25c39b115f1aca750b68
Author: Chen Changcheng <chenchangcheng@kylinos.cn>
HID: picolcd: Use min() macro to simplify code
This commit replaces an open-coded minimum check with the standard min()
macro in hid-picolcd_debugfs.c. It simplifies the logic for limiting the
read size for EEPROM data.
> diff --git a/drivers/hid/hid-picolcd_debugfs.c b/drivers/hid/hid-picolcd_debugfs.c
> --- a/drivers/hid/hid-picolcd_debugfs.c
> +++ b/drivers/hid/hid-picolcd_debugfs.c
> @@ -86,7 +86,7 @@ static ssize_t picolcd_debug_eeprom_read(struct file *f, char __user *u,
> /* prepare buffer with info about what we want to read (addr & len) */
> raw_data[0] = *off & 0xff;
> raw_data[1] = (*off >> 8) & 0xff;
> - raw_data[2] = s < 20 ? s : 20;
> + raw_data[2] = min(s, 20);
[ ... ]
> if (resp->in_report && resp->in_report->id == REPORT_EE_DATA) {
> /* successful read :) */
> ret = resp->raw_data[2];
> if (ret > s)
> ret = s;
> if (copy_to_user(u, resp->raw_data+3, ret))
[Severity: High]
This is a pre-existing issue, but while reviewing this function, can a
malicious or buggy USB device cause an out-of-bounds read here?
If a user reads from the eeprom file with a large size, for example
s = 256, and a malicious device responds with a REPORT_EE_DATA containing
a large embedded length field in resp->raw_data[2] up to 255, ret will take
that device-controlled value.
Since ret (255) would not be greater than s (256), this copy_to_user()
call could attempt to copy up to 255 bytes.
Given that resp->raw_data is a fixed 64-byte array, does this allow reading
past the end of the struct picolcd_pending heap allocation and leaking
adjacent kernel heap memory to userspace?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260728025750.48249-1-chenchangcheng@kylinos.cn?part=3
next prev parent reply other threads:[~2026-07-28 3:06 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-28 2:57 [PATCH 0/4] HID: Address Coccinelle warnings Chen Changcheng
2026-07-28 2:57 ` [PATCH 1/4] HID: intel-quicki2c: Use min() macro to simplify code Chen Changcheng
2026-07-28 3:05 ` sashiko-bot
2026-07-28 2:57 ` [PATCH 2/4] HID: sony: " Chen Changcheng
2026-07-28 2:57 ` [PATCH 3/4] HID: picolcd: " Chen Changcheng
2026-07-28 3:06 ` sashiko-bot [this message]
2026-07-28 2:57 ` [PATCH 4/4] HID: intel-ish-hid: Use secs_to_jiffies() instead of msecs_to_jiffies(sec * MSEC_PER_SEC) Chen Changcheng
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=20260728030635.1C5C51F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=chenchangcheng@kylinos.cn \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
--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 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.