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 75B4F2E5432; Tue, 8 Jul 2025 16:31:29 +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=1751992289; cv=none; b=JvvHUl0SXXnqSSpTLz84LWgV+qi0ziHB+B2NA2hq0r4RaE+UKpWicGUwh6NhjfeDj6l9lxchdMCtBo5xQctgRhozv65RBhuizoftoersjk5GQwk8TFLWZKZ7FAojqm+tO6+LNaGHBO35SISRv/HjYQOf5PqZwkfNIVblXM8m9/c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751992289; c=relaxed/simple; bh=a55HmOkHonpzLWWHtKxCxXJMEFyerS0J3qL4TrBkltg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PwOGW7Ar/+8qkJB4RdYvfpr6RCUXkwTvgIvHRqa7nMaCJWwKbs+saedmC72TNZR37/eM48EGErvgopQTba2E2lMx8hwaCBiXRYRkwYlY7vrEgdoukKbURAOKgGKG+xtoNjqltWd4XgiG0LSkuwn8lyNyO1wk0OUbdj5Y96jl3q0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=wHd2HNaB; 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="wHd2HNaB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 01282C4CEF0; Tue, 8 Jul 2025 16:31:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1751992289; bh=a55HmOkHonpzLWWHtKxCxXJMEFyerS0J3qL4TrBkltg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wHd2HNaBKXY1uwghuZfzhcMAiSHZblnH51iReCNhqxH9xLcDCYpkRRN5LJEqVTeAs ulJyl8/7AVBQLYLdmlxp0kBgCkpIs2CiYw+bctOXcKzTutp56S51v8orLx1CsRD9I3 0hZiW9ciulzxIMg03S19yuXXq7sRU5O6GS724Jzs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable , RD Babiera , Badhri Jagan Sridharan , Heikki Krogerus Subject: [PATCH 6.6 014/132] usb: typec: altmodes/displayport: do not index invalid pin_assignments Date: Tue, 8 Jul 2025 18:22:05 +0200 Message-ID: <20250708162231.152143725@linuxfoundation.org> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250708162230.765762963@linuxfoundation.org> References: <20250708162230.765762963@linuxfoundation.org> User-Agent: quilt/0.68 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.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: RD Babiera commit af4db5a35a4ef7a68046883bfd12468007db38f1 upstream. A poorly implemented DisplayPort Alt Mode port partner can indicate that its pin assignment capabilities are greater than the maximum value, DP_PIN_ASSIGN_F. In this case, calls to pin_assignment_show will cause a BRK exception due to an out of bounds array access. Prevent for loop in pin_assignment_show from accessing invalid values in pin_assignments by adding DP_PIN_ASSIGN_MAX value in typec_dp.h and using i < DP_PIN_ASSIGN_MAX as a loop condition. Fixes: 0e3bb7d6894d ("usb: typec: Add driver for DisplayPort alternate mode") Cc: stable Signed-off-by: RD Babiera Reviewed-by: Badhri Jagan Sridharan Reviewed-by: Heikki Krogerus Link: https://lore.kernel.org/r/20250618224943.3263103-2-rdbabiera@google.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Greg Kroah-Hartman --- drivers/usb/typec/altmodes/displayport.c | 2 +- include/linux/usb/typec_dp.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) --- a/drivers/usb/typec/altmodes/displayport.c +++ b/drivers/usb/typec/altmodes/displayport.c @@ -528,7 +528,7 @@ static ssize_t pin_assignment_show(struc assignments = get_current_pin_assignments(dp); - for (i = 0; assignments; assignments >>= 1, i++) { + for (i = 0; assignments && i < DP_PIN_ASSIGN_MAX; assignments >>= 1, i++) { if (assignments & 1) { if (i == cur) len += sprintf(buf + len, "[%s] ", --- a/include/linux/usb/typec_dp.h +++ b/include/linux/usb/typec_dp.h @@ -56,6 +56,7 @@ enum { DP_PIN_ASSIGN_D, DP_PIN_ASSIGN_E, DP_PIN_ASSIGN_F, /* Not supported after v1.0b */ + DP_PIN_ASSIGN_MAX, }; /* DisplayPort alt mode specific commands */