From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD16F3A782D for ; Thu, 10 Sep 2026 23:36:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.71 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789083372; cv=none; b=ep6VybCTEEsuBLFnqolwudbzL1TdMVD7AohHD8fWl0Fe2TQAOqt7zjtS+srqyhoB/mDm/bUznbND5m+wc0aJcOxbJy4pVZINklaiylAzP8hfvlbvekszRjf82IOEuURSqFXw4uCEqO5NmM2dbEupel5lxaRS6xuK1TBDjQyJ5F8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789083372; c=relaxed/simple; bh=JJzwW/RBzy0my3indWcgFQ7zUPKPqzg47+erEtgY5gc=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=s1QfUYbl4xzXthRxnoAH16m8s2uBpqxYkWS0EFhu5yFHTPhOHHiCsgYdmW9HwVLmJb9IYqHDLNRbVCLl4A/tV51N+XLIv34z3Tga300PusO6S/vAWq5QTTHWEo+xxn5iL5Ye9eeYvoDb7t/HXcGIldEd7IfRV31YN6sjFeXOdoE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jthies.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=NsbqqiDA; arc=none smtp.client-ip=209.85.216.71 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jthies.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="NsbqqiDA" Received: by mail-pj1-f71.google.com with SMTP id 98e67ed59e1d1-39d8646b10eso278981a91.1 for ; Thu, 10 Sep 2026 16:36:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1789083362; x=1789688162; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=zz5k/vH8alNEWC+Sg5nx473Mm7iwMDhzEALYTSQS358=; b=NsbqqiDAsRXcjshBza/wJH3KzYhAO84IOU5oFThdGpHRW7cRyl8dZIZmFajZqw29/b uX5T4QlL6/vYQMRmjNtdiXOKnQvRzXRohpD1IDl1HUs+nHVLRfZ47b/urNqGQPXfuPOB Cw0jeJZBuU3qS2IAAiJt1YYB9MikNIlFKA1nvQLJV/xJCg4ADJUxXKwwq/0yUJ7eVrGC x2mLWbRQp20Yi2RXi4WQ4lThkHZ8gi6KEHymGjFNAKpMchVHDBkak//vsIZASENfjITb WlaIeIyHth0qVkR4sarfQFB1WJ+pzs9156nZFtwc95WzIIZjzPSQUJmfZxs/7EKk5u9T VUPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789083362; x=1789688162; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=zz5k/vH8alNEWC+Sg5nx473Mm7iwMDhzEALYTSQS358=; b=kRmBbvjip4vGW0g+5lUWeoJ5a8ngVMXUmYUafQ0Z2Fn9x/T8jnWsRbmn+02Uj+X8mg 5keMC0+zR7PXJkIvnbYIGL2OK4HnFGAQF4P5dvZ/y7g+BH8gU3HfF5dpSJ/sBRbAcePu ahHIgU0pQgJe5ZZx668y8jCTb6/1VUwAsKoGtTuo80aVWaFpVIt/5cUwdXCCaKANvpFY FICRkA69XZrCRXzBxlNZS4xlblfEqoGl65zHJEjzG7qs7hf4TPA4d7s7o6croPRAuUt0 Js1FMqwLnfvk+hlSFe7n5QVNKarIWdav/+ADjFtZaOCBkAFuCfASHFiqwHMj+HRTwMjf w6Cw== X-Forwarded-Encrypted: i=1; AKwUvBwjxsjnlxJxGACon47KhkPmUN/nDtNy35KS5FGY6Y6Gp7wSNk5YgOKHh2Ey7QYxJN6ZbBqlpw46jN0=@vger.kernel.org X-Gm-Message-State: AFuF++mX8aScpFo84ORTpMWpn9zzOoLqzddHQcuw4je/AlopGSLtjKvx 93OSs40pf3gPxwaxdIld4af8VjlI3vbKa0+JQeJZUqbADtEji14Ts2RKNpg+mdITX3qntJTNrUj n0vY5Mw== X-Received: from dltt19.prod.google.com ([2002:a05:701a:c973:b0:143:1093:eb5a]) (user=jthies job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:2ec4:b0:395:4de5:1054 with SMTP id 98e67ed59e1d1-39d9c0b705fmr2010365a91.16.1789083362130; Thu, 10 Sep 2026 16:36:02 -0700 (PDT) Date: Thu, 10 Sep 2026 23:35:53 +0000 In-Reply-To: <20260910233553.3477055-1-jthies@google.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260910233553.3477055-1-jthies@google.com> X-Mailer: git-send-email 2.55.0.1007.g17ff1f9808-goog Message-ID: <20260910233553.3477055-3-jthies@google.com> Subject: [PATCH v1 2/2] usb: typec: ucsi: displayport: Check CAM to fix OOB altmode array index From: Jameson Thies 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 Content-Type: text/plain; charset="UTF-8" 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 Reviewed-by: Andrei Kuchynski Reviewed-by: Heikki Krogerus Signed-off-by: Jameson Thies --- 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