Linux USB
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: DongliLiu <dongli.liu@outlook.com>
Cc: linux-usb@vger.kernel.org, security@kernel.org
Subject: Re: [PATCH] usb: typec: ucsi: Fix potential stack buffer overflow in altmode registration
Date: Tue, 30 Jun 2026 16:14:58 +0200	[thread overview]
Message-ID: <2026063016-choking-flint-ccad@gregkh> (raw)
In-Reply-To: <KUZPR04MB8968032AEDE5FB1CCFC62D5985F72@KUZPR04MB8968.apcprd04.prod.outlook.com>

On Tue, Jun 30, 2026 at 07:33:09PM +0800, DongliLiu wrote:
> From: DongliLiu <dongli.liu@outlook.com>
> Date: Mon, 30 Jun 2026 19:32:00 +0800
> Subject: [PATCH] usb: typec: ucsi: Fix potential stack buffer overflow in
> altmode registration

Odd, this shouldn't be in the email body.

> 
> cap.num_alt_modes is a u8 hardware register value with a range of 0-255.
> The altmode arrays in ucsi_register_altmodes_nvidia() are fixed at
> UCSI_MAX_ALTMODES (30) elements. Without clamping, a malicious or
> misbehaving hardware could report more than 30 alternate modes, causing
> a write beyond the stack-allocated array bounds.
> 
> Add min_t() to clamp max_altmodes to the array size, preventing the
> overflow.
> 
> Signed-off-by: DongliLiu <dongli.liu@outlook.com>
> ---
>  drivers/usb/typec/ucsi/ucsi.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
> index xxxxxxx..yyyyyyy 100644
> --- a/drivers/usb/typec/ucsi/ucsi.c
> +++ b/drivers/usb/typec/ucsi/ucsi.c
> @@ -xxx,yyy @@@ static int ucsi_register_altmodes_nvidia(struct
> ucsi_connector *con)
>      struct typec_altmode_desc alt[UCSI_MAX_ALTMODES];
>      struct ucsi_altmode orig[UCSI_MAX_ALTMODES];
> -    int max_altmodes = con->ucsi->cap.num_alt_modes;
> +    int max_altmodes = min_t(int, con->ucsi->cap.num_alt_modes,
> +                 UCSI_MAX_ALTMODES);

Patch is line-wrapped and corrupted and can not be applied :(

And no need to cc: security@kernel.org for a public issue like this.

thanks,

greg k-h

      reply	other threads:[~2026-06-30 14:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-30 11:33 [PATCH] usb: typec: ucsi: Fix potential stack buffer overflow in altmode registration DongliLiu
2026-06-30 14:14 ` Greg KH [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=2026063016-choking-flint-ccad@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=dongli.liu@outlook.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=security@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