All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Fil Dunsky" <filipp.dunsky@gmail.com>
Cc: linux-pci@vger.kernel.org, linux-clk@vger.kernel.org,
	linux-phy@lists.infradead.org, devicetree@vger.kernel.org,
	robh@kernel.org, conor+dt@kernel.org, vkoul@kernel.org,
	neil.armstrong@linaro.org, olteanv@gmail.com
Subject: Re: [PATCH 1/8] PCI: dwc: Export the multiplexed MSI interrupt handler
Date: Mon, 23 Nov 2026 18:52:30 +0000	[thread overview]
Message-ID: <sashiko-outbox-229882@kernel.org> (raw)
In-Reply-To: <20261123-b4-cs7542-pcie-v1-1-4cde5201d404@gmail.com>

Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] PCI: dwc: use-after-free in dw_pcie_free_msi() [1]
--

commit 73ef750c2f801a3eaf7bfcf95e0a5bd88aebd4c3
Author: Fil Dunsky <filipp.dunsky@gmail.com>

PCI: dwc: Export the multiplexed MSI interrupt handler

This commit exports dw_handle_msi_irq() so that modular DesignWare PCIe host
glue drivers can dispatch the internal MSI receiver directly from a combined
application interrupt handler.

> diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c
> index bbb02458af58f..1d076bb62783c 100644
> --- a/drivers/pci/controller/dwc/pcie-designware-host.c
> +++ b/drivers/pci/controller/dwc/pcie-designware-host.c
> @@ -85,6 +85,7 @@ void dw_handle_msi_irq(struct dw_pcie_rp *pp)
>  			generic_handle_demux_domain_irq(pp->msi_irq_domain, irq_off + pos);
>  	}
>  }
> +EXPORT_SYMBOL_GPL(dw_handle_msi_irq);
>  
>  /* Chained MSI interrupt service routine */
>  static void dw_chained_msi_isr(struct irq_desc *desc)

[Severity: Critical]
This problem wasn't introduced by this patch, but can dw_handle_msi_irq() hit
a use-after-free on pp->msi_irq_domain when racing with dw_pcie_free_msi()
[1]?

During device unbind or module removal, dw_pcie_free_msi() clears the chained
MSI handlers with irq_set_chained_handler_and_data() and immediately removes
pp->msi_irq_domain without waiting for in-flight interrupts on other CPUs:

drivers/pci/controller/dwc/pcie-designware-host.c:dw_pcie_free_msi() {
	for (ctrl = 0; ctrl < MAX_MSI_CTRLS; ctrl++) {
		if (pp->msi_irq[ctrl] > 0)
			irq_set_chained_handler_and_data(pp->msi_irq[ctrl],
							 NULL, NULL);
	}

	irq_domain_remove(pp->msi_irq_domain);
}

If dw_chained_msi_isr() is already running on another CPU when teardown
starts, dw_handle_msi_irq() will pass the freed pp->msi_irq_domain to
generic_handle_demux_domain_irq():

CPU0                                    CPU1
dw_pcie_free_msi()                      dw_chained_msi_isr()
  irq_set_chained_handler_and_data()
  irq_domain_remove(pp->msi_irq_domain)
                                          dw_handle_msi_irq(pp)
                                            generic_handle_demux_domain_irq(
                                              pp->msi_irq_domain, ...)
                                              <-- use-after-free

Calling synchronize_irq() for each active pp->msi_irq[ctrl] before
irq_domain_remove() would ensure no chained handler is still running.

[1] https://sashiko.dev/#/bug/linux-a392f803-d749-417f-bb89-17e283cf6476

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261123-b4-cs7542-pcie-v1-0-4cde5201d404@gmail.com?part=1

WARNING: multiple messages have this Message-ID (diff)
From: sashiko-bot@kernel.org
To: "Fil Dunsky" <filipp.dunsky@gmail.com>
Cc: linux-pci@vger.kernel.org, linux-clk@vger.kernel.org,
	linux-phy@lists.infradead.org, devicetree@vger.kernel.org,
	robh@kernel.org, conor+dt@kernel.org, vkoul@kernel.org,
	neil.armstrong@linaro.org, olteanv@gmail.com
Subject: Re: [PATCH 1/8] PCI: dwc: Export the multiplexed MSI interrupt handler
Date: Mon, 23 Nov 2026 18:52:30 +0000	[thread overview]
Message-ID: <sashiko-outbox-229882@kernel.org> (raw)
In-Reply-To: <20261123-b4-cs7542-pcie-v1-1-4cde5201d404@gmail.com>

Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] PCI: dwc: use-after-free in dw_pcie_free_msi() [1]
--

commit 73ef750c2f801a3eaf7bfcf95e0a5bd88aebd4c3
Author: Fil Dunsky <filipp.dunsky@gmail.com>

PCI: dwc: Export the multiplexed MSI interrupt handler

This commit exports dw_handle_msi_irq() so that modular DesignWare PCIe host
glue drivers can dispatch the internal MSI receiver directly from a combined
application interrupt handler.

> diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c
> index bbb02458af58f..1d076bb62783c 100644
> --- a/drivers/pci/controller/dwc/pcie-designware-host.c
> +++ b/drivers/pci/controller/dwc/pcie-designware-host.c
> @@ -85,6 +85,7 @@ void dw_handle_msi_irq(struct dw_pcie_rp *pp)
>  			generic_handle_demux_domain_irq(pp->msi_irq_domain, irq_off + pos);
>  	}
>  }
> +EXPORT_SYMBOL_GPL(dw_handle_msi_irq);
>  
>  /* Chained MSI interrupt service routine */
>  static void dw_chained_msi_isr(struct irq_desc *desc)

[Severity: Critical]
This problem wasn't introduced by this patch, but can dw_handle_msi_irq() hit
a use-after-free on pp->msi_irq_domain when racing with dw_pcie_free_msi()
[1]?

During device unbind or module removal, dw_pcie_free_msi() clears the chained
MSI handlers with irq_set_chained_handler_and_data() and immediately removes
pp->msi_irq_domain without waiting for in-flight interrupts on other CPUs:

drivers/pci/controller/dwc/pcie-designware-host.c:dw_pcie_free_msi() {
	for (ctrl = 0; ctrl < MAX_MSI_CTRLS; ctrl++) {
		if (pp->msi_irq[ctrl] > 0)
			irq_set_chained_handler_and_data(pp->msi_irq[ctrl],
							 NULL, NULL);
	}

	irq_domain_remove(pp->msi_irq_domain);
}

If dw_chained_msi_isr() is already running on another CPU when teardown
starts, dw_handle_msi_irq() will pass the freed pp->msi_irq_domain to
generic_handle_demux_domain_irq():

CPU0                                    CPU1
dw_pcie_free_msi()                      dw_chained_msi_isr()
  irq_set_chained_handler_and_data()
  irq_domain_remove(pp->msi_irq_domain)
                                          dw_handle_msi_irq(pp)
                                            generic_handle_demux_domain_irq(
                                              pp->msi_irq_domain, ...)
                                              <-- use-after-free

Calling synchronize_irq() for each active pp->msi_irq[ctrl] before
irq_domain_remove() would ensure no chained handler is still running.

[1] https://sashiko.dev/#/bug/linux-a392f803-d749-417f-bb89-17e283cf6476

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261123-b4-cs7542-pcie-v1-0-4cde5201d404@gmail.com?part=1

-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

  reply	other threads:[~2026-11-23 18:52 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 18:43 [PATCH 0/8] soc: cortina: Add CS7542 PCIe control, SerDes and host support Fil Dunsky
2026-11-23 18:43 ` Fil Dunsky via B4 Relay
2026-11-23 18:43 ` Fil Dunsky via B4 Relay
2026-11-23 18:43 ` [PATCH 1/8] PCI: dwc: Export the multiplexed MSI interrupt handler Fil Dunsky
2026-11-23 18:43   ` Fil Dunsky via B4 Relay
2026-11-23 18:43   ` Fil Dunsky via B4 Relay
2026-11-23 18:52   ` sashiko-bot [this message]
2026-11-23 18:52     ` sashiko-bot
2026-11-23 18:43 ` [PATCH 2/8] dt-bindings: clock: Describe CS7542 PCIe gates and resets Fil Dunsky
2026-11-23 18:43   ` Fil Dunsky via B4 Relay
2026-11-23 18:43   ` Fil Dunsky via B4 Relay
2026-11-23 18:49   ` sashiko-bot
2026-11-23 18:49     ` sashiko-bot
2026-11-24  6:38   ` Krzysztof Kozlowski
2026-11-24  6:38     ` Krzysztof Kozlowski
2026-11-24  6:58     ` Fil Dunsky
2026-11-24  6:58       ` Fil Dunsky
2026-11-23 18:43 ` [PATCH 3/8] clk: Add " Fil Dunsky
2026-11-23 18:43   ` Fil Dunsky via B4 Relay
2026-11-23 18:43   ` Fil Dunsky via B4 Relay
2026-11-23 18:43 ` [PATCH 4/8] dt-bindings: phy: Describe CS7542 PCIe SerDes Fil Dunsky
2026-11-23 18:43   ` Fil Dunsky via B4 Relay
2026-11-23 18:43   ` Fil Dunsky via B4 Relay
2026-11-23 18:43 ` [PATCH 5/8] phy: Add CS7542 PCIe SerDes support Fil Dunsky
2026-11-23 18:43   ` Fil Dunsky via B4 Relay
2026-11-23 18:43   ` Fil Dunsky via B4 Relay
2026-11-23 18:43 ` [PATCH 6/8] dt-bindings: PCI: Describe the CS7542 host controller Fil Dunsky
2026-11-23 18:43   ` Fil Dunsky via B4 Relay
2026-11-23 18:43   ` Fil Dunsky via B4 Relay
2026-11-23 18:48   ` sashiko-bot
2026-11-23 18:48     ` sashiko-bot
2026-11-23 18:43 ` [PATCH 7/8] PCI: cs7542: Add CS7542 PCIe host support Fil Dunsky
2026-11-23 18:43   ` Fil Dunsky via B4 Relay
2026-11-23 18:43   ` Fil Dunsky via B4 Relay
2026-11-23 19:11   ` sashiko-bot
2026-11-23 19:11     ` sashiko-bot
2026-11-23 22:24   ` Bjorn Helgaas
2026-11-23 22:24     ` Bjorn Helgaas
2026-11-23 23:42     ` Fil Dunsky
2026-11-23 23:42       ` Fil Dunsky
2026-11-23 18:43 ` [PATCH 8/8] MAINTAINERS: Add CS7542 PCIe support Fil Dunsky
2026-11-23 18:43   ` Fil Dunsky via B4 Relay
2026-11-23 18:43   ` Fil Dunsky via B4 Relay
2026-11-23 19:11 ` [PATCH 0/8] soc: cortina: Add CS7542 PCIe control, SerDes and host support 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=sashiko-outbox-229882@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=filipp.dunsky@gmail.com \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=neil.armstrong@linaro.org \
    --cc=olteanv@gmail.com \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=vkoul@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.