Re: [PATCH] platform/chrome: wilco_ec: Reject out-of-bounds property length
From: Benson Leung
Date: Wed Nov 18 2026 - 14:51:17 EST
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@xxxxxxxxxxxxxxx
> Signed-off-by: Maoyi Xie <maoyixie.tju@xxxxxxxxx>A
Reviewed-by: Benson Leung <bleung@xxxxxxxxxxxx>
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:
signature.asc
Description: PGP signature