From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B2EF02D8378; Sun, 7 Jun 2026 10:25:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780827937; cv=none; b=S8UkNBAgc/nG5sXEA+Hm4msoohJG9fgPu+Lspy1UBwTi86vorR8VZMD1EtBE+8cb7/DjIK5eg2B4FXtsHD5i7mhuJG8ByRxK/O0bB4Hc1Y4Rfm3s+rs6dAtFvMC4cHiZYmJ9urSZ6y9RzMaUESpFreZTQK2Qu3zI74RWhhVk7UY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780827937; c=relaxed/simple; bh=XOWXn6j0B1uPyGJa25xgZo47HNglwVus+8qkmmY1UAU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=omu3TLa7slxGlU+jXX7XBOwTop0/RgZyM0HW39duW62Y2H5QYcWg9ggBsXBeVNAj499++gUuNeC4JmxEcAwUoNeLr4NiDQTbBazo1wy//zAYYc2K8efhwAzC+NTYJvJ3kmmtkrEHj6U9pxNzW3ojAvKGW9mOpKNjUxZ1AMrlsXE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=lkfGzFqb; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="lkfGzFqb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F06051F00893; Sun, 7 Jun 2026 10:25:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780827936; bh=oUHSoI9kAzleY/gFuv8f7nINigfdDEKNGpd550eYmZQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=lkfGzFqbsmJEUIJ6gx5a1d40uibAQEKUFCpnrjVuDx6sWmMHrVoD3UxmHzT4KLxYd ZwyCbplGa901HJL/iN5GXO/hnRnMWSuBrjYB4NxcZBPSxdLCLUb20rPjukA/ROcYEX V887POYsykc2cgW0TMKF1YSHm4yUfRBpMS9ReFHg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Heikki Krogerus , Benson Leung , Jameson Thies , Nathan Rebello , Johan Hovold , Pooja Katiyar , Hsin-Te Yuan , Abel Vesa , stable , Abel Vesa Subject: [PATCH 6.18 114/315] usb: typec: ucsi: validate connector number in ucsi_connector_change() Date: Sun, 7 Jun 2026 11:58:21 +0200 Message-ID: <20260607095731.825926797@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260607095727.528828913@linuxfoundation.org> References: <20260607095727.528828913@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Greg Kroah-Hartman commit 288a81a8507052bcfbf884d39a463c44c42c5fd9 upstream. The connector number in a UCSI CCI notification is a 7-bit field supplied by the PPM. ucsi_connector_change() uses it to index the ucsi->connector[] array without checking it against the number of connectors the PPM reported at init time, so a buggy or malicious PPM (EC firmware, or an I2C-attached UCSI controller on the ccg / stm32g0 / glink transports) can drive schedule_work() on memory past the end of the array. Reject connector numbers that are zero or exceed cap.num_connectors before dereferencing the array. Assisted-by: gkh_clanker_t1000 Cc: Heikki Krogerus Cc: Benson Leung Cc: Jameson Thies Cc: Nathan Rebello Cc: Johan Hovold Cc: Pooja Katiyar Cc: Hsin-Te Yuan Cc: Abel Vesa Cc: stable Reviewed-by: Abel Vesa Reviewed-by: Heikki Krogerus Reviewed-by: Benson Leung Link: https://patch.msgid.link/2026051351-truck-steadfast-df48@gregkh Signed-off-by: Greg Kroah-Hartman --- drivers/usb/typec/ucsi/ucsi.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) --- a/drivers/usb/typec/ucsi/ucsi.c +++ b/drivers/usb/typec/ucsi/ucsi.c @@ -1325,13 +1325,22 @@ out_unlock: */ void ucsi_connector_change(struct ucsi *ucsi, u8 num) { - struct ucsi_connector *con = &ucsi->connector[num - 1]; + struct ucsi_connector *con; if (!(ucsi->ntfy & UCSI_ENABLE_NTFY_CONNECTOR_CHANGE)) { dev_dbg(ucsi->dev, "Early connector change event\n"); return; } + if (!num || num > ucsi->cap.num_connectors) { + dev_warn_ratelimited(ucsi->dev, + "Bogus connector change on %u (max %u)\n", + num, ucsi->cap.num_connectors); + return; + } + + con = &ucsi->connector[num - 1]; + if (!test_and_set_bit(EVENT_PENDING, &ucsi->flags)) schedule_work(&con->work); }