Skip to content

Commit 7dd08a0

Browse files
Dan Carpentergregkh
authored andcommitted
usb: typec: fix potential out of bounds in ucsi_ccg_update_set_new_cam_cmd()
The "*cmd" variable can be controlled by the user via debugfs. That means "new_cam" can be as high as 255 while the size of the uc->updated[] array is UCSI_MAX_ALTMODES (30). The call tree is: ucsi_cmd() // val comes from simple_attr_write_xsigned() -> ucsi_send_command() -> ucsi_send_command_common() -> ucsi_run_command() // calls ucsi->ops->sync_control() -> ucsi_ccg_sync_control() Fixes: 170a672 ("usb: typec: ucsi: add support for separate DP altmode devices") Cc: stable <stable@kernel.org> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Link: https://lore.kernel.org/r/325102b3-eaa8-4918-a947-22aca1146586@stanley.mountain Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 9cfb31e commit 7dd08a0

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/usb/typec/ucsi/ucsi_ccg.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,8 @@ static void ucsi_ccg_update_set_new_cam_cmd(struct ucsi_ccg *uc,
482482

483483
port = uc->orig;
484484
new_cam = UCSI_SET_NEW_CAM_GET_AM(*cmd);
485+
if (new_cam >= ARRAY_SIZE(uc->updated))
486+
return;
485487
new_port = &uc->updated[new_cam];
486488
cam = new_port->linked_idx;
487489
enter_new_mode = UCSI_SET_NEW_CAM_ENTER(*cmd);

0 commit comments

Comments
 (0)