From: Benson Leung <bleung@google.com>
To: Jameson Thies <jthies@google.com>
Cc: bleung@chromium.org, tzungbi@kernel.org, sre@kernel.org,
fparent@baylibre.com, chrome-platform@lists.linux.dev,
linux-pm@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH v1] power: supply: cros_usbpd: Limit port counts to EC_USB_PD_MAX_PORTS
Date: Wed, 22 Jul 2026 19:54:53 +0000 [thread overview]
Message-ID: <amEgDZews_De0mH8@google.com> (raw)
In-Reply-To: <20260722195059.1420738-1-jthies@google.com>
[-- Attachment #1: Type: text/plain, Size: 1924 bytes --]
On Wed, Jul 22, 2026 at 07:50:59PM +0000, Jameson Thies wrote:
> Currently the cros_usbpd-charger driver probe iterates based on raw
> charger port count returned by the embedded controller. The only check
> is against the number of USB PD ports which the embedded controller
> also defines. A malicious embedded controller could return an inaccurate
> port count (up to 255) resulting in an out of bounds write and
> subsequent memory corruption.
>
> Update helper functions in cros_usbpd-charger to limit port counts to
> EC_USB_PD_MAX_PORTS.
>
> Fixes: 3af15cfacd1e ("power: supply: cros: add support for dedicated port")
> Cc: stable@vger.kernel.org
> Signed-off-by: Jameson Thies <jthies@google.com>
Reviewed-by: Benson Leung <bleung@chromium.org>
> ---
> drivers/power/supply/cros_usbpd-charger.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/drivers/power/supply/cros_usbpd-charger.c b/drivers/power/supply/cros_usbpd-charger.c
> index 308e1d4e6dd8..82185ee33fd4 100644
> --- a/drivers/power/supply/cros_usbpd-charger.c
> +++ b/drivers/power/supply/cros_usbpd-charger.c
> @@ -125,6 +125,11 @@ static int cros_usbpd_charger_get_num_ports(struct charger_data *charger)
> if (ret < 0)
> return ret;
>
> + if (resp.port_count > EC_USB_PD_MAX_PORTS) {
> + dev_warn(charger->dev, "Charge port count out of bounds\n");
> + return EC_USB_PD_MAX_PORTS;
> + }
> +
> return resp.port_count;
> }
>
> @@ -138,6 +143,11 @@ static int cros_usbpd_charger_get_usbpd_num_ports(struct charger_data *charger)
> if (ret < 0)
> return ret;
>
> + if (resp.num_ports > EC_USB_PD_MAX_PORTS) {
> + dev_warn(charger->dev, "USB PD port count out of bounds\n");
> + return EC_USB_PD_MAX_PORTS;
> + }
> +
> return resp.num_ports;
> }
>
>
> base-commit: 17376e7311cdec252b61cb1ecec43be61907781b
> --
> 2.55.0.229.g6434b31f56-goog
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
prev parent reply other threads:[~2026-07-22 19:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-22 19:50 [PATCH v1] power: supply: cros_usbpd: Limit port counts to EC_USB_PD_MAX_PORTS Jameson Thies
2026-07-22 19:54 ` 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=amEgDZews_De0mH8@google.com \
--to=bleung@google.com \
--cc=bleung@chromium.org \
--cc=chrome-platform@lists.linux.dev \
--cc=fparent@baylibre.com \
--cc=jthies@google.com \
--cc=linux-pm@vger.kernel.org \
--cc=sre@kernel.org \
--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