From: Jameson Thies <jthies@google.com>
To: heikki.krogerus@linux.intel.com, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: bleung@chromium.org, gregkh@linuxfoundation.org,
akuchynski@chromium.org, Jameson Thies <jthies@google.com>
Subject: [PATCH v1 2/2] usb: typec: ucsi: displayport: Check CAM to fix OOB altmode array index
Date: Thu, 10 Sep 2026 23:35:53 +0000 [thread overview]
Message-ID: <20260910233553.3477055-3-jthies@google.com> (raw)
In-Reply-To: <20260910233553.3477055-1-jthies@google.com>
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. If the
current CAM is greater than UCSI_MAX_ALTMODES and not 0xff, return an
invalid error from ucsi_displayport_enter().
Reviewed-by: Benson Leung <bleung@chromium.org>
Reviewed-by: Andrei Kuchynski <akuchynski@chromium.org>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Jameson Thies <jthies@google.com>
---
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;
}
--
2.55.0.1007.g17ff1f9808-goog
next prev parent reply other threads:[~2026-09-10 23:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-10 23:35 [PATCH v1 0/2] Cleanup UCSI DisplayPort OOB fix Jameson Thies
2026-09-10 23:35 ` [PATCH v1 1/2] Revert "usb: typec: ucsi: displayport: Fix OOB altmode array index" Jameson Thies
2026-09-10 23:35 ` Jameson Thies [this message]
2026-09-11 13:31 ` [PATCH v1 0/2] Cleanup UCSI DisplayPort OOB fix Heikki Krogerus
2026-09-11 18:29 ` 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=20260910233553.3477055-3-jthies@google.com \
--to=jthies@google.com \
--cc=akuchynski@chromium.org \
--cc=bleung@chromium.org \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@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®