* [PATCH] usb: typec: tcpm/tcpci_maxim: Fix bounds check in process_rx()
@ 2025-05-02 23:57 Amit Sunil Dhamne via B4 Relay
2025-05-02 23:58 ` kernel test robot
2025-05-06 11:23 ` Heikki Krogerus
0 siblings, 2 replies; 3+ messages in thread
From: Amit Sunil Dhamne via B4 Relay @ 2025-05-02 23:57 UTC (permalink / raw)
To: Heikki Krogerus, Greg Kroah-Hartman, Badhri Jagan Sridharan
Cc: André Draszik, Peter Griffin, Tudor Ambarus, RD Babiera,
linux-usb, linux-kernel, stable, Amit Sunil Dhamne, Kyle Tso
From: Amit Sunil Dhamne <amitsd@google.com>
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 <amitsd@google.com>
Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
Reviewed-by: Kyle Tso <kyletso@google.com>
---
drivers/usb/typec/tcpm/tcpci_maxim_core.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/typec/tcpm/tcpci_maxim_core.c b/drivers/usb/typec/tcpm/tcpci_maxim_core.c
index fd1b80593367641a6f997da2fb97a2b7238f6982..648311f5e3cf135f23b5cc0668001d2f177b9edd 100644
--- a/drivers/usb/typec/tcpm/tcpci_maxim_core.c
+++ b/drivers/usb/typec/tcpm/tcpci_maxim_core.c
@@ -166,7 +166,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;
}
---
base-commit: ebd297a2affadb6f6f4d2e5d975c1eda18ac762d
change-id: 20250421-b4-new-fix-pd-rx-count-79297ba619b7
Best regards,
--
Amit Sunil Dhamne <amitsd@google.com>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] usb: typec: tcpm/tcpci_maxim: Fix bounds check in process_rx()
2025-05-02 23:57 [PATCH] usb: typec: tcpm/tcpci_maxim: Fix bounds check in process_rx() Amit Sunil Dhamne via B4 Relay
@ 2025-05-02 23:58 ` kernel test robot
2025-05-06 11:23 ` Heikki Krogerus
1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2025-05-02 23:58 UTC (permalink / raw)
To: Amit Sunil Dhamne via B4 Relay; +Cc: stable, oe-kbuild-all
Hi,
Thanks for your patch.
FYI: kernel test robot notices the stable kernel rule is not satisfied.
The check is based on https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html#option-1
Rule: add the tag "Cc: stable@vger.kernel.org" in the sign-off area to have the patch automatically included in the stable tree.
Subject: [PATCH] usb: typec: tcpm/tcpci_maxim: Fix bounds check in process_rx()
Link: https://lore.kernel.org/stable/20250502-b4-new-fix-pd-rx-count-v1-1-e5711ed09b3d%40google.com
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] usb: typec: tcpm/tcpci_maxim: Fix bounds check in process_rx()
2025-05-02 23:57 [PATCH] usb: typec: tcpm/tcpci_maxim: Fix bounds check in process_rx() Amit Sunil Dhamne via B4 Relay
2025-05-02 23:58 ` kernel test robot
@ 2025-05-06 11:23 ` Heikki Krogerus
1 sibling, 0 replies; 3+ messages in thread
From: Heikki Krogerus @ 2025-05-06 11:23 UTC (permalink / raw)
To: amitsd
Cc: Greg Kroah-Hartman, Badhri Jagan Sridharan, André Draszik,
Peter Griffin, Tudor Ambarus, RD Babiera, linux-usb, linux-kernel,
stable, Kyle Tso
On Fri, May 02, 2025 at 04:57:03PM -0700, Amit Sunil Dhamne via B4 Relay wrote:
> From: Amit Sunil Dhamne <amitsd@google.com>
>
> 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 <amitsd@google.com>
> Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
> Reviewed-by: Kyle Tso <kyletso@google.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
> drivers/usb/typec/tcpm/tcpci_maxim_core.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/typec/tcpm/tcpci_maxim_core.c b/drivers/usb/typec/tcpm/tcpci_maxim_core.c
> index fd1b80593367641a6f997da2fb97a2b7238f6982..648311f5e3cf135f23b5cc0668001d2f177b9edd 100644
> --- a/drivers/usb/typec/tcpm/tcpci_maxim_core.c
> +++ b/drivers/usb/typec/tcpm/tcpci_maxim_core.c
> @@ -166,7 +166,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;
> }
>
> ---
> base-commit: ebd297a2affadb6f6f4d2e5d975c1eda18ac762d
> change-id: 20250421-b4-new-fix-pd-rx-count-79297ba619b7
>
> Best regards,
> --
> Amit Sunil Dhamne <amitsd@google.com>
>
--
heikki
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-05-06 11:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-02 23:57 [PATCH] usb: typec: tcpm/tcpci_maxim: Fix bounds check in process_rx() Amit Sunil Dhamne via B4 Relay
2025-05-02 23:58 ` kernel test robot
2025-05-06 11:23 ` Heikki Krogerus
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox