]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
usb: typec: altmodes/displayport: do not index invalid pin_assignments
authorRD Babiera <rdbabiera@google.com>
Wed, 18 Jun 2025 22:49:42 +0000 (22:49 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 24 Jun 2025 14:42:55 +0000 (15:42 +0100)
commitaf4db5a35a4ef7a68046883bfd12468007db38f1
tree07a620a10bee33b4292d9feb8bbb6d3433c6eb33
parent2831a81077f5162f104ba5a97a7d886eb371c21c
usb: typec: altmodes/displayport: do not index invalid pin_assignments

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 <stable@kernel.org>
Signed-off-by: RD Babiera <rdbabiera@google.com>
Reviewed-by: Badhri Jagan Sridharan <badhri@google.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20250618224943.3263103-2-rdbabiera@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/typec/altmodes/displayport.c
include/linux/usb/typec_dp.h