From: sashiko-bot@kernel.org
To: "Svyatoslav Ryhel" <clamor95@gmail.com>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH v2 3/4] usb: chipidea: tegra: Avoid controller/PHY init if bus is externally controlled
Date: Sat, 23 May 2026 09:17:03 +0000 [thread overview]
Message-ID: <20260523091704.039CA1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260523083013.46372-4-clamor95@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Out-of-bounds I/O memory access in `tegra_ehci_hub_control()` due to unvalidated `wIndex`.
--
commit 60717c8d1b44f3d9bbb2d143c18add1a1d62f035
Author: Svyatoslav Ryhel <clamor95@gmail.com>
usb: chipidea: tegra: Avoid controller/PHY init if bus is externally controlled
This commit skips the registration of the USB controller and PHY
initialization if they are externally controlled. Since the USB PHY
in Tegra controls clock gates required by the controller itself, it
defers this configuration to the device that controls the bus.
> diff --git a/drivers/usb/chipidea/ci_hdrc_tegra.c b/drivers/usb/chipidea/ci_hdrc_tegra.c
> index 372788f0f9701..a19cb3b33bf37 100644
> --- a/drivers/usb/chipidea/ci_hdrc_tegra.c
> +++ b/drivers/usb/chipidea/ci_hdrc_tegra.c
[ ... ]
> @@ -342,12 +348,14 @@ static int tegra_usb_probe(struct platform_device *pdev)
> if (of_usb_get_phy_mode(pdev->dev.of_node) == USBPHY_INTERFACE_MODE_ULPI)
> usb->data.flags &= ~CI_HDRC_SUPPORTS_RUNTIME_PM;
>
> - usb->dev = ci_hdrc_add_device(&pdev->dev, pdev->resource,
> - pdev->num_resources, &usb->data);
[Severity: High]
This is a pre-existing issue, but does tegra_ehci_hub_control() have an
out-of-bounds I/O memory access?
When handling root hub control requests, the core USB code in
rh_call_control() passes the raw, user-supplied wIndex (e.g., from usbfs via
the USBDEVFS_CONTROL ioctl) to the HCD's hub_control callback.
In tegra_ehci_hub_control(), which is passed in the usb->data structure here,
the pointer to the port status register is calculated without bounds checking
on wIndex:
status_reg = &ehci->regs->port_status[(wIndex & 0xff) - 1]
If wIndex & 0xff evaluates to 0, the calculation produces an index of -1
(pointing to the configured_flag register). If it is a large number like 255,
it results in an index of 254, reading far past the port_status array which
has a size of HCS_N_PORTS_MAX (15).
Could sending a SetPortFeature request with wValue = USB_PORT_FEAT_RESET
and a crafted wIndex allow a user with access to the root hub device node to
force the driver to perform multiple reads and writes at arbitrary MMIO
offsets?
> + if (!usb->externally_controlled) {
> + usb->dev = ci_hdrc_add_device(&pdev->dev, pdev->resource,
> + pdev->num_resources, &usb->data);
> + if (IS_ERR(usb->dev)) {
> + err = dev_err_probe(&pdev->dev, PTR_ERR(usb->dev),
> + "failed to add HDRC device");
> + goto phy_shutdown;
> + }
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260523083013.46372-1-clamor95@gmail.com?part=3
next prev parent reply other threads:[~2026-05-23 9:17 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-23 8:30 [PATCH v2 0/4] usb: chipidea: tegra: Add external control option Svyatoslav Ryhel
2026-05-23 8:30 ` [PATCH v2 1/4] dt-bindings: usb: Move Tegra-specific Chipidea USB properties into a dedicated schema Svyatoslav Ryhel
2026-05-23 8:30 ` [PATCH v2 2/4] dt-bindings: usb: chipidea,usb2-tegra: Document nvidia,external-control property Svyatoslav Ryhel
2026-05-23 8:47 ` sashiko-bot
2026-05-23 8:30 ` [PATCH v2 3/4] usb: chipidea: tegra: Avoid controller/PHY init if bus is externally controlled Svyatoslav Ryhel
2026-05-23 9:17 ` sashiko-bot [this message]
2026-05-23 8:30 ` [PATCH v2 4/4] usb: chipidea: tegra: Expose tegra_usb structure Svyatoslav Ryhel
2026-05-23 9:28 ` sashiko-bot
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=20260523091704.039CA1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=clamor95@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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