From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 273402727F3; Wed, 8 Apr 2026 18:47:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775674069; cv=none; b=IIh2U5hyvISiOSS8aIznMm8B9tYlgZsUJOOSrKvNQhSvoOL5sjpu0ykraIbkxR42IZ2BH4tabrU4demNbXYZtFiBzpoG6tYbu2rrKDvhSkv/1zgf6ziVbXD0upM/6sF1gLcDn5KpCzsLPmEjfj2E078W9+LWDyE9PaIPZNuS4XY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775674069; c=relaxed/simple; bh=KS23aE4q+grC5khx69v3SPq6OyUXDwybRkgwoza4b/4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EtkH8R89EROWFWjCPmPh0yb29XS1m0HnQIcVhjUfgfl2Z+idVSXlHWRYiNW2x3IeiChokijnss7t7XFSSrxqDLHwm3a9A1CrrR133gHGafbwvjPWeVKSHPNgV2p7+Ww26rW7NVl+LdPcfKBpa1AptM57uargVwwGEmZKQTWdhh4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=eow5+JD1; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="eow5+JD1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AFC64C19421; Wed, 8 Apr 2026 18:47:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1775674069; bh=KS23aE4q+grC5khx69v3SPq6OyUXDwybRkgwoza4b/4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eow5+JD1GcOMDEWmmuCsVFKoX3BiL+RHC5rscEX5mpgjqfmzXfv8qHloMhxOdtoC4 hGcov4Lg4kPMbfTbosy54uYXNWQDhwiyewHRNF2efKBrf3ulZhmBFUlhtVOpaopiGB TZCUpX5UlePzQ9gvqNLm7sUXtRfxzzte7X1aS5lU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable , Heikki Krogerus , Nathan Rebello Subject: [PATCH 6.12 197/242] usb: typec: ucsi: validate connector number in ucsi_notify_common() Date: Wed, 8 Apr 2026 20:03:57 +0200 Message-ID: <20260408175934.456700429@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260408175927.064985309@linuxfoundation.org> References: <20260408175927.064985309@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Nathan Rebello commit d2d8c17ac01a1b1f638ea5d340a884ccc5015186 upstream. The connector number extracted from CCI via UCSI_CCI_CONNECTOR() is a 7-bit field (0-127) that is used to index into the connector array in ucsi_connector_change(). However, the array is only allocated for the number of connectors reported by the device (typically 2-4 entries). A malicious or malfunctioning device could report an out-of-range connector number in the CCI, causing an out-of-bounds array access in ucsi_connector_change(). Add a bounds check in ucsi_notify_common(), the central point where CCI is parsed after arriving from hardware, so that bogus connector numbers are rejected before they propagate further. Fixes: bdc62f2bae8f ("usb: typec: ucsi: Simplified registration and I/O API") Cc: stable Reviewed-by: Heikki Krogerus Signed-off-by: Nathan Rebello Link: https://patch.msgid.link/20260313222453.123-1-nathan.c.rebello@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/typec/ucsi/ucsi.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) --- a/drivers/usb/typec/ucsi/ucsi.c +++ b/drivers/usb/typec/ucsi/ucsi.c @@ -42,8 +42,13 @@ void ucsi_notify_common(struct ucsi *ucs if (cci & UCSI_CCI_BUSY) return; - if (UCSI_CCI_CONNECTOR(cci)) - ucsi_connector_change(ucsi, UCSI_CCI_CONNECTOR(cci)); + if (UCSI_CCI_CONNECTOR(cci)) { + if (UCSI_CCI_CONNECTOR(cci) <= ucsi->cap.num_connectors) + ucsi_connector_change(ucsi, UCSI_CCI_CONNECTOR(cci)); + else + dev_err(ucsi->dev, "bogus connector number in CCI: %lu\n", + UCSI_CCI_CONNECTOR(cci)); + } if (cci & UCSI_CCI_ACK_COMPLETE && test_and_clear_bit(ACK_PENDING, &ucsi->flags))