Re: [PATCH 02/10] Input: cyapa - validate firmware image size in cyapa_pip_check_fw()

From: Dmitry Torokhov

Date: Mon Nov 23 2026 - 18:34:10 EST


On Mon, Nov 23, 2026 at 06:31:08PM +0000, Lee Jones wrote:
> cyapa_pip_check_fw() parses the firmware header, the trailing
> application integrity record, and the application rows without verifying
> that the supplied firmware buffer is large enough to hold them.
>
> A truncated firmware image smaller than struct cyapa_tsg_bin_image_head
> causes an out-of-bounds read in cyapa_pip_fw_head_check() and can
> underflow the unsigned size subtraction in
> cyapa_get_image_record_data_num(). An image containing a valid header
> but zero complete flash records causes image_records[flash_records_count
> - 1] to read before the start of fw->data. Finally, an image whose
> metadata specifies an app_len exceeding the available application
> records reads past the end of fw->data while computing app_crc.
>
> Validate the header size, ensure at least one flash record is present,
> and bound the application row count against the non-integrity record
> count before dereferencing image_records.
>
> Fixes: 5812d3067294 ("Input: cyapa - add gen5 trackpad firmware update support")
> Closes: https://sashiko.dev/#/bug/linux-cc76de59-950f-4e64-b49e-7605164e02a9
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Lee Jones <lee@xxxxxxxxxx>

Applied with some minor edits, thank you.

--
Dmitry