Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Chen-Yu Tsai" <wenst@chromium.org>
Cc: conor+dt@kernel.org, robh@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v8 14/16] power: sequencing: pcie-m2: Split Bluetooth unit based on interface
Date: Fri, 04 Sep 2026 09:08:00 +0000	[thread overview]
Message-ID: <20260904090800.CA7CD1F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260904084158.1341550-15-wenst@chromium.org>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

New issues:
- [Medium] Splitting the Bluetooth unit into separate UART and USB units introduces a hardware state conflict where one interface can unexpectedly physically power off the device while the other is still using it.

Pre-existing issues:
- [High] Teardown asymmetry and lack of synchronization in the provider driver allows active consumers to trigger a UAF and kernel oops.
--

commit 04bd68356c9e71e9f7432f78d28c9d647b96c081
Author: Chen-Yu Tsai <wenst@chromium.org>
Subject: power: sequencing: pcie-m2: Split Bluetooth unit based on interface

This commit splits the Bluetooth power sequencing unit for M.2 PCIe connectors
into separate UART and USB units. This allows either interface to independently
toggle power, specifically enabling hardware resets during initialization or
recovery for serdev-based drivers.

> diff --git a/drivers/power/sequencing/pwrseq-pcie-m2.c b/drivers/power/sequencing/pwrseq-pcie-m2.c
> index 987faa9f3b3ba..f7bcc8bb4c775 100644
> --- a/drivers/power/sequencing/pwrseq-pcie-m2.c
> +++ b/drivers/power/sequencing/pwrseq-pcie-m2.c
[ ... ]
> @@ -83,8 +83,22 @@ static int pwrseq_pci_m2_e_bt_disable(struct pwrseq_device *pwrseq)
>  	return gpiod_set_value_cansleep(ctx->w_disable2_gpio, 1);
>  }
>  
> -static const struct pwrseq_unit_data pwrseq_pcie_m2_e_bt_unit_data = {
> -	.name = "bt-enable",
> +/*
> + * XXX There are two Bluetooth units to allow either one to be able to power
> + * off and thus reset the controller. In practice only one of the interfaces
> + * is used, so there is no conflict. However userspace could power off the
> + * USB unit by disabling the associated USB port, without the UART unit or
> + * its consumer ever knowing.
> + */
> +static const struct pwrseq_unit_data pwrseq_pcie_m2_e_bt_uart_unit_data = {
> +	.name = "bt-uart-enable",
> +	.deps = pwrseq_pcie_m2_unit_deps,
> +	.enable = pwrseq_pci_m2_e_bt_enable,
> +	.disable = pwrseq_pci_m2_e_bt_disable,
> +};
> +
> +static const struct pwrseq_unit_data pwrseq_pcie_m2_e_bt_usb_unit_data = {
> +	.name = "bt-usb-enable",
> +	.deps = pwrseq_pcie_m2_unit_deps,
> +	.enable = pwrseq_pci_m2_e_bt_enable,
> +	.disable = pwrseq_pci_m2_e_bt_disable,
> +};

[Severity: Medium]
Since both pwrseq_pcie_m2_e_bt_uart_unit_data and 
pwrseq_pcie_m2_e_bt_usb_unit_data use the same w_disable2_gpio in their
disable callback, does this split introduce a hardware state conflict?

If userspace or the USB core disables the USB interface, the USB unit's
refcount will drop to 0 and physically assert the shared GPIO. Can this 
unexpectedly cut power to the Bluetooth controller while the UART consumer 
is still actively using it, violating its state machine?

[ ... ]

drivers/power/sequencing/pwrseq-pcie-m2.c:pwrseq_pcie_m2_remove() {
    ...
	pwrseq_pcie_m2_remove_serdev(ctx, NULL);
	mutex_destroy(&ctx->list_lock);

	regulator_bulk_free(ctx->num_vregs, ctx->regs);
}

[Severity: High]
This isn't a bug introduced by this patch, but could manually freeing the 
regulators here create a use-after-free window?

Because devm_pwrseq_device_register() is used in probe, the logical
sequencer device is unregistered by devres after pwrseq_pcie_m2_remove()
returns. 

If an active PCIe or USB consumer (which are not created by this driver and
lack device links) invokes pwrseq_enable() during this window, it will call 
pwrseq_pcie_m2_vregs_enable() which dereferences the freed regulator pointers
inside ctx->regs:

drivers/power/sequencing/pwrseq-pcie-m2.c:pwrseq_pcie_m2_vregs_enable() {
    ...
	return regulator_bulk_enable(ctx->num_vregs, ctx->regs);
}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260904084158.1341550-1-wenst@chromium.org?part=14

  reply	other threads:[~2026-09-04  9:08 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-04  8:41 [PATCH v8 00/16] arm64: mediatek: Add M.2 E-key slot on Chromebooks Chen-Yu Tsai
2026-09-04  8:41 ` [PATCH v8 01/16] device property: Add fwnode_graph_get_port_by_id() Chen-Yu Tsai
2026-09-04  8:54   ` sashiko-bot
2026-09-04 20:18   ` Sakari Ailus
2026-09-04  8:41 ` [PATCH v8 02/16] device property: Add fwnode_graph_get_next_port_endpoint() Chen-Yu Tsai
2026-09-04 20:22   ` Sakari Ailus
2026-09-04  8:41 ` [PATCH v8 03/16] power: sequencing: Add pwrseq_get_state() Chen-Yu Tsai
2026-09-04  8:57   ` sashiko-bot
2026-09-04  8:41 ` [PATCH v8 04/16] usb: hub: Use assign_bit() in usb_hub_set_port_power() Chen-Yu Tsai
2026-09-04  8:41 ` [PATCH v8 05/16] usb: hub: Return actual error from hub_configure() in hub_probe() Chen-Yu Tsai
2026-09-04  8:41 ` [PATCH v8 06/16] usb: hub: Associate port@ fwnode with USB port device Chen-Yu Tsai
2026-09-04  8:41 ` [PATCH v8 07/16] usb: core: Move struct usb_port and related APIs to port.h Chen-Yu Tsai
2026-09-04 16:40   ` Alan Stern
2026-09-04 16:44   ` Greg Kroah-Hartman
2026-09-04 17:24     ` Chen-Yu Tsai
2026-09-04 17:52       ` Greg Kroah-Hartman
2026-09-05  8:19         ` Andy Shevchenko
2026-09-05 11:30           ` Greg Kroah-Hartman
2026-09-04  8:41 ` [PATCH v8 08/16] usb: hub: Pass |struct usb_port*| to usb_port_is_power_on() Chen-Yu Tsai
2026-09-04 16:44   ` Alan Stern
2026-09-04  8:41 ` [PATCH v8 09/16] usb: hub: Use usb_hub_set_port_power() to control port power everywhere Chen-Yu Tsai
2026-09-04  8:41 ` [PATCH v8 10/16] usb: hub: Power on connected M.2 E-key connectors with power sequencing API Chen-Yu Tsai
2026-09-04  9:10   ` sashiko-bot
2026-09-04  8:41 ` [PATCH v8 11/16] dt-bindings: usb: mediatek,mtk-xhci: Switch to ports for USB connections Chen-Yu Tsai
2026-09-04  8:41 ` [PATCH v8 12/16] power: sequencing: pcie-m2: support matching on remote "port" node Chen-Yu Tsai
2026-09-04  8:41 ` [PATCH v8 13/16] power: sequencing: pcie-m2: Add usb and sdio targets for E-key connector Chen-Yu Tsai
2026-09-04  8:41 ` [PATCH v8 14/16] power: sequencing: pcie-m2: Split Bluetooth unit based on interface Chen-Yu Tsai
2026-09-04  9:08   ` sashiko-bot [this message]
2026-09-04  8:41 ` [PATCH v8 15/16] arm64: dts: mediatek: mt8195-cherry: Add M.2 E-key slot Chen-Yu Tsai
2026-09-04  8:41 ` [PATCH v8 16/16] arm64: dts: mediatek: mt8188-geralt: Add WiFi/BT as " Chen-Yu Tsai

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=20260904090800.CA7CD1F00A3D@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=wenst@chromium.org \
    /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