mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Jameson Thies <jthies@google.com>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	bleung@chromium.org, gregkh@linuxfoundation.org,
	akuchynski@chromium.org, stable@vger.kernel.org
Subject: Re: [PATCH v1] usb: typec: ucsi: displayport: Fix OOB altmode array index
Date: Mon, 31 Aug 2026 12:37:08 +0200	[thread overview]
Message-ID: <apVZVCzUEXp1Ahv2@black.igk.intel.com> (raw)
In-Reply-To: <20260825234545.2076049-1-jthies@google.com>

On Tue, Aug 25, 2026 at 11:45:45PM +0000, Jameson Thies wrote:
> The UCSI displayport driver indexes the connector's port altmode array
> with the GET_CURRENT_CAM response after checking it is not 0xff. The
> port altmode array is UCSI_MAX_ALTMODES elements long. If the PPM
> returns an invalid GET_CURRENT_CAM response above UCSI_MAX_ALTMODES and
> not equal to 0xff, the kernel may crash with an array index OOB error.
> 
> Update the UCSI displayport driver to verify the current cam is less
> than UCSI_MAX_ALTMODES before accessing the port altmode array.
> 
> Fixes: af8622f6a585 ("usb: typec: ucsi: Support for DisplayPort alt mode")
> Cc: stable@vger.kernel.org
> Signed-off-by: Jameson Thies <jthies@google.com>
> ---
>  drivers/usb/typec/ucsi/displayport.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/ucsi/displayport.c b/drivers/usb/typec/ucsi/displayport.c
> index 7067f2561b84..8d2032d0762c 100644
> --- a/drivers/usb/typec/ucsi/displayport.c
> +++ b/drivers/usb/typec/ucsi/displayport.c
> @@ -74,7 +74,7 @@ static int ucsi_displayport_enter(struct typec_altmode *alt, u32 *vdo)
>  		cur = 0xff;

Can you remove the above line while at it?

>  	}
>  
> -	if (cur != 0xff) {
> +	if (cur < UCSI_MAX_ALTMODES) {

Shouldn't that be the other way around?

>  		ret = dp->con->port_altmode[cur] == alt ? 0 : -EBUSY;
>  		goto err_unlock;
>  	}

Thanks,

-- 
heikki

  parent reply	other threads:[~2026-08-31 10:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-25 23:45 Jameson Thies
2026-08-26 21:03 ` Benson Leung
2026-08-31 10:37 ` Heikki Krogerus [this message]
2026-08-31 11:35   ` Andrei Kuchynski
2026-09-02  1:15     ` Jameson Thies

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=apVZVCzUEXp1Ahv2@black.igk.intel.com \
    --to=heikki.krogerus@linux.intel.com \
    --cc=akuchynski@chromium.org \
    --cc=bleung@chromium.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jthies@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=stable@vger.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

all inboxes | Powered by JetHome®