From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) (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 B67FC374E79 for ; Fri, 4 Sep 2026 23:44:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.198 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788565445; cv=none; b=bBz0HIZo7vuu3GretPYizdYM98HRGQDvxnfsaMAoKVGwf16yLQURU++70/eoL9NeaZqqU6Fy9V9E5mGQ+XMIb0kVc54ALLZe7FfIhHqV58ih+72JNKCSVmLAILudU7P8/7op2jx+7/VGHi/FBEZWdiudNqoUwig82E9ma+ySkMc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788565445; c=relaxed/simple; bh=6j7QtbafL0GjId7kZIPTH6hRjGmJBCaIWXYGOyGCfIM=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=seVItqItHlM3UDwCDSB66Hcu/QsmoRFzLAs1QIxQ0RUoAwYfay8AWiLvUtwpE0oS1DqIEq0hO584zElLQvycBkwc8RFrp8vKCuLY4ais1tB0T6vhr841llJkp7D+aMhwIB//aPl3JeolNgNhnWaaX15hSKWtcDf/WPhWyFwQf84= 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=A/BLVheY; arc=none smtp.client-ip=209.85.215.198 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="A/BLVheY" Received: by mail-pg1-f198.google.com with SMTP id 41be03b00d2f7-c89704da8c7so1782638a12.0 for ; Fri, 04 Sep 2026 16:44:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1788565444; x=1789170244; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:mime-version:date:from :to:cc:subject:date:message-id:reply-to:content-type; bh=43MbP1qjgGN4vZdi/2GkDDZJfA5MhGqHcArs08teQ7w=; b=A/BLVheYo8MtMcD/W7YdnE6CUvW3KfqkaZ5WaVV4L1xt+h1g5cBjK39A+ZlEqgc9zJ KFUOdT9QFVdA0yogtzLCyfym1/VHZC0RxNLI9DJ5NDZHymmcIlkg+of8nnwk3KB7zwn4 +Ma8DLQwLsw2qYeAMKyXtbBOlGK8Z7HFb9egxwLtzfnGiFt0luc1Sx2Y594X9jkDiMHH xuHQhCK8Sh3g4Otp5sEYN3456rBmnr4pfdTjdg0PNY3hw4visMbyalF81Hh5gaqbWRDL N4WzE972n4gB7DzBTV+G34Vf13/5G8C63WL9UbtELnuKtOlmmzjkARi9uVexyV2w/bK1 B41w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788565444; x=1789170244; h=content-type:cc:to:from:subject:message-id:mime-version:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=43MbP1qjgGN4vZdi/2GkDDZJfA5MhGqHcArs08teQ7w=; b=hJgTWCdhuMPMdmfleCCFLhsDopNYFHPd0jcbhxHTjC75yfJ/JxQmMa+abUbvIkBID7 hTT+z74spP03Sv27LZwhpc519dtaANoCu8Gx0CfTiBROksZ+dvdGyeEosJwOock2ftjT s/q2JbRlqlNRIN4tAlkk7vNlaD+1rK1fXHMYu7wFj/P+CppgjdoFD37YSuS0dMNQhGcy MSwcZs95S0CupzGg1MDZtgo44Sq511iDykbl/gBBsuBl88L1HuSnySqNFH+C8XJzK8oo WWqUNQ5ORf3P1a95vbjN+LX3APSTIJZ/At/kJGZQmDlZnPjZzL3M2PiLKyvxrKmLkCT7 VNjQ== X-Forwarded-Encrypted: i=1; AKwUvBxRvC/ZUALGDaPOExSEiRTQmxYT0DSypt4jRwErZBhFrj4CrZtWskl8248a29oJGs5+vJiYpwPe9I80dQ4=@vger.kernel.org X-Gm-Message-State: AFuF++kF9tVd15m++p0t68S9hdS6eLpFoGA/XPThcuQqvBExOZjcXlcH MDXXhu3mwB7BXhZ0QUZDaw3+k3MYfvrs0Izt0BW+sK5fA8rgF5jYTkfRzuaqbl0wczWmGqtxiX9 2J3sEIA== X-Received: from dycag16.prod.google.com ([2002:a05:7300:fa10:b0:328:430e:e346]) (user=jthies job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:a06:b0:3d3:aec2:4dcc with SMTP id adf61e73a8af0-3da3a0fd0f3mr15160633637.24.1788565443779; Fri, 04 Sep 2026 16:44:03 -0700 (PDT) Date: Fri, 4 Sep 2026 23:44:01 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.55.0.979.g7e5102b832-goog Message-ID: <20260904234401.2339633-1-jthies@google.com> Subject: [PATCH v2] usb: typec: ucsi: displayport: 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 , stable@vger.kernel.org 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. Fixes: af8622f6a585 ("usb: typec: ucsi: Support for DisplayPort alt mode") Cc: stable@vger.kernel.org Signed-off-by: Jameson Thies --- 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