]> git.hungrycats.org Git - linux/commit
usb: typec: fix potential out of bounds in ucsi_ccg_update_set_new_cam_cmd()
authorDan Carpenter <dan.carpenter@linaro.org>
Mon, 4 Nov 2024 17:16:42 +0000 (20:16 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 17 Nov 2024 13:59:38 +0000 (14:59 +0100)
commitd76923164705821aa1b01b8d9d1741f20c654ab4
tree3c0dbf52ac135eab72f3bcdf2dbb6fb82610069d
parent6e2848d1c8c0139161e69ac0a94133e90e9988e8
usb: typec: fix potential out of bounds in ucsi_ccg_update_set_new_cam_cmd()

commit 7dd08a0b4193087976db6b3ee7807de7e8316f96 upstream.

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: 170a6726d0e2 ("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>
drivers/usb/typec/ucsi/ucsi_ccg.c