All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: Pengpeng Hou <pengpeng@iscas.ac.cn>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] USB: serial: io_ti: reject oversized boot-mode firmware images
Date: Mon, 6 Jul 2026 14:21:11 +0200	[thread overview]
Message-ID: <akudt5BoC9MmcF1P@hovoldconsulting.com> (raw)
In-Reply-To: <20260701053535.39951-1-pengpeng@iscas.ac.cn>

On Wed, Jul 01, 2026 at 01:35:35PM +0800, Pengpeng Hou wrote:
> do_boot_mode() allocates a fixed 15.5 KiB staging buffer plus the I2C
> image header and then copies fw->size - 4 bytes into it.
> check_fw_sanity() validates the firmware's internal record accounting,
> but the boot-mode copy still needs to prove that the raw firmware
> payload fits in the fixed staging buffer.
> 
> Reject firmware images that are shorter than the skipped 4-byte prefix
> or whose remaining payload exceeds the staging buffer before copying the
> data.

check_fw_sanity() already makes sure that the image has a 7-byte header
so the commit message and check below needs to be updated.

Also, how was this issue found?

> Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>

Please add a Fixes tag as well.

> ---
>  drivers/usb/serial/io_ti.c |    6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
> index d48819d7..3bdcbd6f 100644
> --- a/drivers/usb/serial/io_ti.c
> +++ b/drivers/usb/serial/io_ti.c
> @@ -1466,6 +1466,12 @@ static int do_boot_mode(struct edgeport_serial *serial,
>  		/* Allocate a 15.5k buffer + 3 byte header */
>  		buffer_size = (((1024 * 16) - 512) +
>  					sizeof(struct ti_i2c_image_header));
> +		if (fw->size < 4 || fw->size - 4 > buffer_size) {

Just drop the < 4 check, or possibly keep it with a comment about it
being redundant because of check_fw_sanity().

> +			dev_err(dev, "%s - firmware image is too large\n",
> +				__func__);
> +			return -EINVAL;
> +		}
> +
>  		buffer = kmalloc(buffer_size, GFP_KERNEL);
>  		if (!buffer)
>  			return -ENOMEM;

Johan

      reply	other threads:[~2026-07-06 12:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-01  5:35 [PATCH] USB: serial: io_ti: reject oversized boot-mode firmware images Pengpeng Hou
2026-07-06 12:21 ` Johan Hovold [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=akudt5BoC9MmcF1P@hovoldconsulting.com \
    --to=johan@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=pengpeng@iscas.ac.cn \
    /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.