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 2D3282DEA96; Tue, 15 Jul 2025 13:52:36 +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=1752587556; cv=none; b=KSHYgUXBJAzg0uLODuxPbe4Hge3UqvqWAhAcPU2J+Os54ddTmyBUHauDw3gy+5kD0O4I1PiuNFAMxsLY5aEkEjzeX7YQQSTU+IRrxKciHM6dm3td+ttIimeOsFhbFEeFSzLMpGFPfnYpT6mHxwPKofupi3ZklNDDvZMzQ+lEYmI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752587556; c=relaxed/simple; bh=yT4oCVJHMGQfC6D1/ObxZeEdnNaUDqSHXC/Dknz6NvQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=i8Tap30io6lFvCugK7Seh8XIIyxRj+WC0Bxo7+87hJj1n9pG5+j/EdYgqSg9mZ2xOCcKMZjeV4b2Kmhir8aJZsXI6yz8taHg0wQYdolXuxxbqoO1ATL7Q7IWBNuGrp6sllQNq6DLtPz6zURBR4HUAKQDEhrSIZqvY+lxiZ6Lljk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=hCfG6oyL; 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="hCfG6oyL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AF7F1C4CEE3; Tue, 15 Jul 2025 13:52:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1752587556; bh=yT4oCVJHMGQfC6D1/ObxZeEdnNaUDqSHXC/Dknz6NvQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hCfG6oyL44cQ2vrVGA20SbBfkccm/xsp57cg7ofIEv8LP4vd4QvWhWKkXw7NmDqVD fhXzaO2Yx/hY2+8tH51UCW97khvOHpWx1oqwnTYDARsplVJ8Bf4uAzM4Ibad3hMIEr uc7CA5mno60eIC4xp5oKVJhspOQDT8bGJlwB4etA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Amit Sunil Dhamne , Badhri Jagan Sridharan , Kyle Tso , stable , Heikki Krogerus , Sasha Levin Subject: [PATCH 5.10 029/208] usb: typec: tcpm/tcpci_maxim: Fix bounds check in process_rx() Date: Tue, 15 Jul 2025 15:12:18 +0200 Message-ID: <20250715130812.000666093@linuxfoundation.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250715130810.830580412@linuxfoundation.org> References: <20250715130810.830580412@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 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Amit Sunil Dhamne [ Upstream commit 0736299d090f5c6a1032678705c4bc0a9511a3db ] Register read of TCPC_RX_BYTE_CNT returns the total size consisting of: PD message (pending read) size + 1 Byte for Frame Type (SOP*) This is validated against the max PD message (`struct pd_message`) size without accounting for the extra byte for the frame type. Note that the struct pd_message does not contain a field for the frame_type. This results in false negatives when the "PD message (pending read)" is equal to the max PD message size. Fixes: 6f413b559f86 ("usb: typec: tcpci_maxim: Chip level TCPC driver") Signed-off-by: Amit Sunil Dhamne Signed-off-by: Badhri Jagan Sridharan Reviewed-by: Kyle Tso Cc: stable Link: https://lore.kernel.org/stable/20250502-b4-new-fix-pd-rx-count-v1-1-e5711ed09b3d%40google.com Reviewed-by: Heikki Krogerus Link: https://lore.kernel.org/r/20250502-b4-new-fix-pd-rx-count-v1-1-e5711ed09b3d@google.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/typec/tcpm/tcpci_maxim.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/typec/tcpm/tcpci_maxim.c b/drivers/usb/typec/tcpm/tcpci_maxim.c index df5887db46946..d694094084f85 100644 --- a/drivers/usb/typec/tcpm/tcpci_maxim.c +++ b/drivers/usb/typec/tcpm/tcpci_maxim.c @@ -165,7 +165,8 @@ static void process_rx(struct max_tcpci_chip *chip, u16 status) return; } - if (count > sizeof(struct pd_message) || count + 1 > TCPC_RECEIVE_BUFFER_LEN) { + if (count > sizeof(struct pd_message) + 1 || + count + 1 > TCPC_RECEIVE_BUFFER_LEN) { dev_err(chip->dev, "Invalid TCPC_RX_BYTE_CNT %d\n", count); return; } -- 2.39.5