usb: typec: fix potential array underflow in ucsi_ccg_sync_control()
BugLink: https://bugs.launchpad.net/bugs/2101915
[ Upstream commit e56aac6e5a25630645607b6856d4b2a17b2311a5 ]
The "command" variable can be controlled by the user via debugfs. The
worry is that if con_index is zero then "&uc->ucsi->connector[con_index
- 1]" would be an array underflow.
Fixes: 170a6726d0 ("usb: typec: ucsi: add support for separate DP altmode devices")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/c69ef0b3-61b0-4dde-98dd-97b97f81d912@stanley.mountain
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
[koichiroden: adjusted patch due to missing commits:
13f2ec3115c8 ("usb: typec: ucsi: simplify command sending API")
584e8df58942 ("usb: typec: ucsi: extract common code for command handling")]
CVE-2024-53203
Signed-off-by: Koichiro Den <koichiro.den@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
This commit is contained in:
committed by
Stefan Bader
parent
0c9f335a22
commit
7e8fa789ed
@@ -585,6 +585,10 @@ static int ucsi_ccg_sync_write(struct ucsi *ucsi, unsigned int offset,
|
||||
uc->has_multiple_dp) {
|
||||
con_index = (uc->last_cmd_sent >> 16) &
|
||||
UCSI_CMD_CONNECTOR_MASK;
|
||||
if (con_index == 0) {
|
||||
ret = -EINVAL;
|
||||
goto err_clear_bit;
|
||||
}
|
||||
con = &uc->ucsi->connector[con_index - 1];
|
||||
ucsi_ccg_update_set_new_cam_cmd(uc, con, (u64 *)val);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user