From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: "Ajay Gupta" <ajayg@nvidia.com>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Dmitry Baryshkov" <dmitry.baryshkov@linaro.org>,
"Uwe Kleine-König" <u.kleine-koenig@baylibre.com>,
"Haotien Hsu" <haotienh@nvidia.com>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] usb: typec: fix potential out of bounds in ucsi_ccg_update_set_new_cam_cmd()
Date: Tue, 5 Nov 2024 11:32:46 +0200 [thread overview]
Message-ID: <ZynmPkv8wXNRjUQS@kuha.fi.intel.com> (raw)
In-Reply-To: <325102b3-eaa8-4918-a947-22aca1146586@stanley.mountain>
On Mon, Nov 04, 2024 at 08:16:42PM +0300, Dan Carpenter wrote:
> 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")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
> drivers/usb/typec/ucsi/ucsi_ccg.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/usb/typec/ucsi/ucsi_ccg.c b/drivers/usb/typec/ucsi/ucsi_ccg.c
> index ba58d11907bc..bccfc03b5986 100644
> --- a/drivers/usb/typec/ucsi/ucsi_ccg.c
> +++ b/drivers/usb/typec/ucsi/ucsi_ccg.c
> @@ -482,6 +482,8 @@ static void ucsi_ccg_update_set_new_cam_cmd(struct ucsi_ccg *uc,
>
> port = uc->orig;
> new_cam = UCSI_SET_NEW_CAM_GET_AM(*cmd);
> + if (new_cam >= ARRAY_SIZE(uc->updated))
> + return;
> new_port = &uc->updated[new_cam];
> cam = new_port->linked_idx;
> enter_new_mode = UCSI_SET_NEW_CAM_ENTER(*cmd);
> --
> 2.45.2
--
heikki
prev parent reply other threads:[~2024-11-05 9:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-04 17:16 Dan Carpenter
2024-11-05 9:32 ` Heikki Krogerus [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZynmPkv8wXNRjUQS@kuha.fi.intel.com \
--to=heikki.krogerus@linux.intel.com \
--cc=ajayg@nvidia.com \
--cc=dan.carpenter@linaro.org \
--cc=dmitry.baryshkov@linaro.org \
--cc=gregkh@linuxfoundation.org \
--cc=haotienh@nvidia.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=u.kleine-koenig@baylibre.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®