Skip to content

Commit 7329753

Browse files
amitsd2smb49
authored andcommitted
usb: typec: tcpm/tcpci_maxim: Fix bounds check in process_rx()
BugLink: https://bugs.launchpad.net/bugs/2119603 commit 0736299d090f5c6a1032678705c4bc0a9511a3db upstream. 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: 6f413b5 ("usb: typec: tcpci_maxim: Chip level TCPC driver") Signed-off-by: Amit Sunil Dhamne <amitsd@google.com> Signed-off-by: Badhri Jagan Sridharan <badhri@google.com> Reviewed-by: Kyle Tso <kyletso@google.com> Cc: stable <stable@kernel.org> Link: https://lore.kernel.org/stable/20250502-b4-new-fix-pd-rx-count-v1-1-e5711ed09b3d%40google.com Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Link: https://lore.kernel.org/r/20250502-b4-new-fix-pd-rx-count-v1-1-e5711ed09b3d@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Manuel Diewald <manuel.diewald@canonical.com> Signed-off-by: Mehmet Basaran <mehmet.basaran@canonical.com>
1 parent fff80e2 commit 7329753

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/usb/typec/tcpm/tcpci_maxim_core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ static void process_rx(struct max_tcpci_chip *chip, u16 status)
166166
return;
167167
}
168168

169-
if (count > sizeof(struct pd_message) || count + 1 > TCPC_RECEIVE_BUFFER_LEN) {
169+
if (count > sizeof(struct pd_message) + 1 ||
170+
count + 1 > TCPC_RECEIVE_BUFFER_LEN) {
170171
dev_err(chip->dev, "Invalid TCPC_RX_BYTE_CNT %d\n", count);
171172
return;
172173
}

0 commit comments

Comments
 (0)