lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <ZzNBS4M9c0tjSmX1@kuha.fi.intel.com>
Date: Tue, 12 Nov 2024 13:51:39 +0200
From: Heikki Krogerus <heikki.krogerus@...ux.intel.com>
To: Dan Carpenter <dan.carpenter@...aro.org>
Cc: Ajay Gupta <ajayg@...dia.com>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Dmitry Baryshkov <dmitry.baryshkov@...aro.org>,
	Uwe Kleine-König <u.kleine-koenig@...libre.com>,
	Haotien Hsu <haotienh@...dia.com>, linux-usb@...r.kernel.org,
	linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org
Subject: Re: [PATCH] usb: typec: fix potential array underflow in
 ucsi_ccg_sync_control()

On Mon, Nov 11, 2024 at 02:08:06PM +0300, Dan Carpenter wrote:
> 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: 170a6726d0e2 ("usb: typec: ucsi: add support for separate DP altmode devices")
> Signed-off-by: Dan Carpenter <dan.carpenter@...aro.org>

Reviewed-by: Heikki Krogerus <heikki.krogerus@...ux.intel.com>

> ---
>  drivers/usb/typec/ucsi/ucsi_ccg.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/usb/typec/ucsi/ucsi_ccg.c b/drivers/usb/typec/ucsi/ucsi_ccg.c
> index bccfc03b5986..fcb8e61136cf 100644
> --- a/drivers/usb/typec/ucsi/ucsi_ccg.c
> +++ b/drivers/usb/typec/ucsi/ucsi_ccg.c
> @@ -644,6 +644,10 @@ static int ucsi_ccg_sync_control(struct ucsi *ucsi, u64 command)
>  	    uc->has_multiple_dp) {
>  		con_index = (uc->last_cmd_sent >> 16) &
>  			UCSI_CMD_CONNECTOR_MASK;
> +		if (con_index == 0) {
> +			ret = -EINVAL;
> +			goto unlock;
> +		}
>  		con = &uc->ucsi->connector[con_index - 1];
>  		ucsi_ccg_update_set_new_cam_cmd(uc, con, &command);
>  	}
> @@ -651,6 +655,7 @@ static int ucsi_ccg_sync_control(struct ucsi *ucsi, u64 command)
>  	ret = ucsi_sync_control_common(ucsi, command);
>  
>  	pm_runtime_put_sync(uc->dev);
> +unlock:
>  	mutex_unlock(&uc->lock);
>  
>  	return ret;
> -- 
> 2.45.2

-- 
heikki

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ