Chrome platform driver development
 help / color / mirror / Atom feed
From: Tzung-Bi Shih <tzungbi@kernel.org>
To: Alexis Savery <asavery@google.com>
Cc: chrome-platform@lists.linux.dev
Subject: Re: [PATCH v3] platform/chrome: lightbar: Limit payload size to EC packet limit
Date: Thu, 30 Jul 2026 03:32:49 +0000	[thread overview]
Message-ID: <amrF4dQ8TjxOZGMf@google.com> (raw)
In-Reply-To: <20260730005956.559287-1-asavery@google.com>

On Wed, Jul 29, 2026 at 05:59:56PM -0700, Alexis Savery wrote:
> The LIGHTBAR_CMD_SET_PROGRAM_EX command encapsulates its payload data
> with an 8-bit size field `uint8_t size` and is natively capped by the V3

The u8 size field can't wrap or contain the payload itself.  To be more
technically accurate, please rephrase "encapsulates".

> packet bounds limit array `EC_LPC_HOST_PACKET_SIZE`. However, the driver
> currently allows the payload chunk to bypass this protocol limit if the
> SPI transmission layer negotiates a larger physical `max_request`.

EC_LPC_HOST_PACKET_SIZE is only for LPC.  Protocol SPI uses another value
(e.g., SPI_MAX_REQUEST_SIZE).

> @@ -496,9 +496,14 @@ static ssize_t program_store(struct device *dev, struct device_attribute *attr,
>  			return -EINVAL;
>  		}
>  	} else {
> +		/*
> +		 * The EC limits all version 3 host packets to EC_LPC_HOST_PACKET_SIZE.
> +		 */
>  		extra_bytes = offsetof(typeof(*param), set_program_ex) +
>  			sizeof(param->set_program_ex);
> -		max_size = ec->ec_dev->max_request - extra_bytes;
> +		max_size = min_t(size_t, ec->ec_dev->max_request,
> +				 EC_LPC_HOST_PACKET_SIZE);
> +		max_size -= extra_bytes;

How about:

    max_size = min(ec->ec_dev->max_request - extra_bytes,
                   sizeof(param->set_program_ex.size));

      reply	other threads:[~2026-07-30  3:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-29 22:14 [PATCH] platform/chrome: lightbar: Enforce 8-bit payload limit Alexis Savery
2026-07-29 23:54 ` Benson Leung
2026-07-30  0:59 ` [PATCH v2] platform/chrome: lightbar: Limit payload size to EC bounding macro Alexis Savery
2026-07-30  0:59 ` [PATCH v3] platform/chrome: lightbar: Limit payload size to EC packet limit Alexis Savery
2026-07-30  3:32   ` Tzung-Bi Shih [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=amrF4dQ8TjxOZGMf@google.com \
    --to=tzungbi@kernel.org \
    --cc=asavery@google.com \
    --cc=chrome-platform@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