Linux Input/HID development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Aibing Chen" <chenaibing@cmss.chinamobile.com>
Cc: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH] Input: ili210x - widen firmware address types to u32
Date: Sun, 29 Nov 2026 09:11:09 +0000	[thread overview]
Message-ID: <sashiko-outbox-239433@kernel.org> (raw)
In-Reply-To: <20261129090341.1179-1-chenaibing@cmss.chinamobile.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] Input: ili210x - u16 parameters in ili210x_firmware_update()
  truncate end addresses
- [Low] Input: ili210x - missing Fixes trailer for u16 firmware address
  truncation
--

commit 367981bad9bc63de88c9f1f6d4141cec44ab2560
Author: Aibing Chen <chenaibing@cmss.chinamobile.com>

> Input: ili210x - widen firmware address types to u32
>
> The firmware write command uses a 3-byte address field, but the
> address variables (end, start, fw_addr, ac_end, df_end) are typed as
> u16, which truncates addresses at 0xffff.  The firmware blob validation
> allows the last block to end at SZ_64K (0x10000), so df_end can be
> 0x10000 -- which truncates to 0 in a u16, making the upper byte of the
> 3-byte address always 0.
>
> Widen the address types to u32 so that the full 3-byte address range
> is usable and the upper byte in the write command reflects the actual
> address.  For the CRC field, write 0x00 for the upper byte directly:
> CRC-CCITT always produces a 16-bit value, so the upper byte is
> constant, which also silences the Smatch warning about shifting a
> 16-bit value by 16.
>
> Suggested-by: sashiko-bot <sashiko-bot@kernel.org>
> Signed-off-by: Aibing Chen <chenaibing@cmss.chinamobile.com>

[Severity: Low]
This fixes a bug in ili251x firmware update support.  Should this
include:

  Fixes: c6ac8f0b4ca9 ("Input: ili210x - add ili251x firmware update support")

> diff --git a/drivers/input/touchscreen/ili210x.c b/drivers/input/touchscreen/ili210x.c
> index 03e4451d6393c..2e4681813731b 100644
> --- a/drivers/input/touchscreen/ili210x.c
> +++ b/drivers/input/touchscreen/ili210x.c

[ ... ]

> @@ -868,7 +868,7 @@ static ssize_t ili210x_firmware_update_store(struct device *dev,
>  {
>  	struct i2c_client *client = to_i2c_client(dev);
>  	const char *fwname = ILI251X_FW_FILENAME;
> -	u16 ac_end, df_end;
> +	u32 ac_end, df_end;
>  	int error;
>  
>  	const struct firmware *fw __free(firmware) = NULL;

[Severity: High]
Does ili210x_firmware_update() still truncate ac_end and df_end to u16?

ili210x_firmware_update_store() passes ac_end and df_end through
ili210x_firmware_update() before reaching ili210x_do_firmware_update():

drivers/input/touchscreen/ili210x.c:ili210x_firmware_update() {
	static ssize_t ili210x_firmware_update(struct device *dev, const u8 *fwbuf,
					       u16 ac_end, u16 df_end)
	{
	...
		error = ili210x_do_firmware_update(priv, fwbuf, ac_end, df_end);
}

When df_end is SZ_64K (0x10000), ili210x_firmware_update() truncates it
back to 0.  In ili251x_firmware_write_to_ic(), start is 0xf000 and end is
0, so the u32 length expression end - start - 2 wraps around to
0xffff0ffe and causes crc_ccitt() to read ~4 GiB out of bounds past the
64 KiB fwbuf buffer.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261129090341.1179-1-chenaibing@cmss.chinamobile.com?part=1

      reply	other threads:[~2026-11-29  9:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-29  9:03 [PATCH] Input: ili210x - widen firmware address types to u32 Aibing Chen
2026-11-29  9:11 ` 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=sashiko-outbox-239433@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=chenaibing@cmss.chinamobile.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox