* Re: [PATCH v2] usb: typec: ucsi: displayport: Fix OOB altmode array index
2026-09-04 23:44 [PATCH v2] usb: typec: ucsi: displayport: Fix OOB altmode array index Jameson Thies
@ 2026-09-05 0:53 ` Benson Leung
2026-09-07 9:44 ` Andrei Kuchynski
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Benson Leung @ 2026-09-05 0:53 UTC (permalink / raw)
To: Jameson Thies
Cc: heikki.krogerus, linux-usb, linux-kernel, bleung, gregkh,
akuchynski, stable
[-- Attachment #1: Type: text/plain, Size: 1870 bytes --]
On Fri, Sep 04, 2026 at 11:44:01PM +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>
Reviewed-by: Benson Leung <bleung@chromium.org>
> ---
> Changes in v2:
> - removed 0xff alt mode assignement when GET_CURRENT_CAM returns an error.
> - return -EINVAL when alt mode index above UCSI_MAX_ALTMODES is returned.
>
> drivers/usb/typec/ucsi/displayport.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/typec/ucsi/displayport.c b/drivers/usb/typec/ucsi/displayport.c
> index 7067f2561b84..572da7bbd29c 100644
> --- a/drivers/usb/typec/ucsi/displayport.c
> +++ b/drivers/usb/typec/ucsi/displayport.c
> @@ -71,11 +71,14 @@ static int ucsi_displayport_enter(struct typec_altmode *alt, u32 *vdo)
> if (ret < 0) {
> if (ucsi->version > 0x0100)
> goto err_unlock;
> - cur = 0xff;
> }
>
> if (cur != 0xff) {
> - ret = dp->con->port_altmode[cur] == alt ? 0 : -EBUSY;
> + if (cur < UCSI_MAX_ALTMODES)
> + ret = dp->con->port_altmode[cur] == alt ? 0 : -EBUSY;
> + else
> + ret = -EINVAL;
> +
> goto err_unlock;
> }
>
>
> base-commit: cee9395acd8043be0644b25c34bfa86623f2b935
> --
> 2.55.0.979.g7e5102b832-goog
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH v2] usb: typec: ucsi: displayport: Fix OOB altmode array index
2026-09-04 23:44 [PATCH v2] usb: typec: ucsi: displayport: Fix OOB altmode array index Jameson Thies
2026-09-05 0:53 ` Benson Leung
@ 2026-09-07 9:44 ` Andrei Kuchynski
2026-09-07 17:43 ` Heikki Krogerus
2026-09-10 12:39 ` Greg KH
3 siblings, 0 replies; 6+ messages in thread
From: Andrei Kuchynski @ 2026-09-07 9:44 UTC (permalink / raw)
To: Jameson Thies
Cc: heikki.krogerus, linux-usb, linux-kernel, bleung, gregkh, stable
On Sat, Sep 5, 2026 at 1:44 AM Jameson Thies <jthies@google.com> 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>
Reviewed-by: Andrei Kuchynski <akuchynski@chromium.org>
> ---
> Changes in v2:
> - removed 0xff alt mode assignement when GET_CURRENT_CAM returns an error.
> - return -EINVAL when alt mode index above UCSI_MAX_ALTMODES is returned.
>
> drivers/usb/typec/ucsi/displayport.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/typec/ucsi/displayport.c b/drivers/usb/typec/ucsi/displayport.c
> index 7067f2561b84..572da7bbd29c 100644
> --- a/drivers/usb/typec/ucsi/displayport.c
> +++ b/drivers/usb/typec/ucsi/displayport.c
> @@ -71,11 +71,14 @@ static int ucsi_displayport_enter(struct typec_altmode *alt, u32 *vdo)
> if (ret < 0) {
> if (ucsi->version > 0x0100)
> goto err_unlock;
> - cur = 0xff;
> }
>
> if (cur != 0xff) {
> - ret = dp->con->port_altmode[cur] == alt ? 0 : -EBUSY;
> + if (cur < UCSI_MAX_ALTMODES)
> + ret = dp->con->port_altmode[cur] == alt ? 0 : -EBUSY;
> + else
> + ret = -EINVAL;
> +
> goto err_unlock;
> }
>
>
> base-commit: cee9395acd8043be0644b25c34bfa86623f2b935
> --
> 2.55.0.979.g7e5102b832-goog
>
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH v2] usb: typec: ucsi: displayport: Fix OOB altmode array index
2026-09-04 23:44 [PATCH v2] usb: typec: ucsi: displayport: Fix OOB altmode array index Jameson Thies
2026-09-05 0:53 ` Benson Leung
2026-09-07 9:44 ` Andrei Kuchynski
@ 2026-09-07 17:43 ` Heikki Krogerus
2026-09-10 12:39 ` Greg KH
3 siblings, 0 replies; 6+ messages in thread
From: Heikki Krogerus @ 2026-09-07 17:43 UTC (permalink / raw)
To: Jameson Thies; +Cc: linux-usb, linux-kernel, bleung, gregkh, akuchynski, stable
On Fri, Sep 04, 2026 at 11:44:01PM +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>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
> Changes in v2:
> - removed 0xff alt mode assignement when GET_CURRENT_CAM returns an error.
> - return -EINVAL when alt mode index above UCSI_MAX_ALTMODES is returned.
>
> drivers/usb/typec/ucsi/displayport.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/typec/ucsi/displayport.c b/drivers/usb/typec/ucsi/displayport.c
> index 7067f2561b84..572da7bbd29c 100644
> --- a/drivers/usb/typec/ucsi/displayport.c
> +++ b/drivers/usb/typec/ucsi/displayport.c
> @@ -71,11 +71,14 @@ static int ucsi_displayport_enter(struct typec_altmode *alt, u32 *vdo)
> if (ret < 0) {
> if (ucsi->version > 0x0100)
> goto err_unlock;
> - cur = 0xff;
> }
>
> if (cur != 0xff) {
> - ret = dp->con->port_altmode[cur] == alt ? 0 : -EBUSY;
> + if (cur < UCSI_MAX_ALTMODES)
> + ret = dp->con->port_altmode[cur] == alt ? 0 : -EBUSY;
> + else
> + ret = -EINVAL;
> +
> goto err_unlock;
> }
>
>
> base-commit: cee9395acd8043be0644b25c34bfa86623f2b935
> --
> 2.55.0.979.g7e5102b832-goog
--
heikki
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH v2] usb: typec: ucsi: displayport: Fix OOB altmode array index
2026-09-04 23:44 [PATCH v2] usb: typec: ucsi: displayport: Fix OOB altmode array index Jameson Thies
` (2 preceding siblings ...)
2026-09-07 17:43 ` Heikki Krogerus
@ 2026-09-10 12:39 ` Greg KH
2026-09-10 19:52 ` Jameson Thies
3 siblings, 1 reply; 6+ messages in thread
From: Greg KH @ 2026-09-10 12:39 UTC (permalink / raw)
To: Jameson Thies
Cc: heikki.krogerus, linux-usb, linux-kernel, bleung, akuchynski, stable
On Fri, Sep 04, 2026 at 11:44:01PM +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>
> ---
> Changes in v2:
> - removed 0xff alt mode assignement when GET_CURRENT_CAM returns an error.
> - return -EINVAL when alt mode index above UCSI_MAX_ALTMODES is returned.
Does not apply against 7.3-rc2 :(
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH v2] usb: typec: ucsi: displayport: Fix OOB altmode array index
2026-09-10 12:39 ` Greg KH
@ 2026-09-10 19:52 ` Jameson Thies
0 siblings, 0 replies; 6+ messages in thread
From: Jameson Thies @ 2026-09-10 19:52 UTC (permalink / raw)
To: Greg KH
Cc: heikki.krogerus, linux-usb, linux-kernel, bleung, akuchynski, stable
Hi Greg.
> Does not apply against 7.3-rc2 :(
7.3-rc2 and usb-next include the v1 version of this patch which fixes
the OOB issue but doesn't incorporate Heikki's or Andrei's feedback.
I'll send a quick series to revert the existing change and followup
with the v2 version.
- Jameson
^ permalink raw reply [flat|nested] 6+ messages in thread