Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Benson Leung <bleung@chromium.org>
To: Maoyi Xie <maoyixie.tju@gmail.com>
Cc: Tzung-Bi Shih <tzungbi@kernel.org>,
	Benson Leung <bleung@chromium.org>,
	chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH] platform/chrome: wilco_ec: Reject out-of-bounds property length
Date: Wed, 18 Nov 2026 11:49:24 -0800	[thread overview]
Message-ID: <av4BREfkXS_6DWkY@google.com> (raw)
In-Reply-To: <20261118101555.3467162-1-maoyixie.tju@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1837 bytes --]

Hi Maoyi,


On Wed, Nov 18, 2026 at 06:15:55PM +0800, Maoyi Xie wrote:
> wilco_ec_get_property() copies rs.length bytes from rs.data into
> prop_msg->data without checking rs.length, which comes from the EC.
> Both buffers hold WILCO_EC_PROPERTY_MAX_SIZE (4) bytes, so a larger
> length reads past rs on the stack and writes past the caller's message.
> 
> Return -EBADMSG for such a length, as the file does for other bad
> responses.
> 
> Found with a CodeQL-based static analysis tool that we are developing.
> I used an LLM to help write this patch and a userspace harness. The
> harness runs the unmodified properties.c against a model of the EC
> under AddressSanitizer. It reports the copy for lengths 5 to 255, and
> nothing with this patch. Not tested on hardware, only compile-tested
> with W=1.
> 
> Fixes: 0c0b7ea23aed ("platform/chrome: wilco_ec: Add property helper library")
> Cc: stable@vger.kernel.org
> Signed-off-by: Maoyi Xie <maoyixie.tju@gmail.com>A

Reviewed-by: Benson Leung <bleung@chromium.org>

Thanks,
Benson

> ---
>  drivers/platform/chrome/wilco_ec/properties.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/platform/chrome/wilco_ec/properties.c b/drivers/platform/chrome/wilco_ec/properties.c
> index 9951c8db04da065..4ca7e874804c28e 100644
> --- a/drivers/platform/chrome/wilco_ec/properties.c
> +++ b/drivers/platform/chrome/wilco_ec/properties.c
> @@ -70,6 +70,8 @@ int wilco_ec_get_property(struct wilco_ec_device *ec,
>  	ret = send_property_msg(ec, &rq, &rs);
>  	if (ret < 0)
>  		return ret;
> +	if (rs.length > WILCO_EC_PROPERTY_MAX_SIZE)
> +		return -EBADMSG;
>  
>  	prop_msg->length = rs.length;
>  	memcpy(prop_msg->data, rs.data, rs.length);
> 
> base-commit: 7e1392a42ea288d70a266f6553fe06f57f8647ea
> -- 
> 2.34.1
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

      reply	other threads:[~2026-11-18 19:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18 10:15 [PATCH] platform/chrome: wilco_ec: Reject out-of-bounds property length Maoyi Xie
2026-11-18 19:49 ` Benson Leung [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=av4BREfkXS_6DWkY@google.com \
    --to=bleung@chromium.org \
    --cc=chrome-platform@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maoyixie.tju@gmail.com \
    --cc=stable@vger.kernel.org \
    --cc=tzungbi@kernel.org \
    /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