All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] PCI: xgene-msi: Fix a potential UAF in xgene_msi_probe
@ 2023-09-25  6:21 ` Dinghao Liu
  0 siblings, 0 replies; 12+ messages in thread
From: Dinghao Liu @ 2023-09-25  6:21 UTC (permalink / raw)
  To: dinghao.liu
  Cc: Toan Le, Lorenzo Pieralisi, Krzysztof Wilczyński,
	Rob Herring, Bjorn Helgaas, Duc Dang, Tanmay Inamdar,
	Marc Zyngier, linux-pci, linux-arm-kernel, linux-kernel

xgene_allocate_domains() will call irq_domain_remove() to free
msi->inner_domain on failure. However, its caller, xgene_msi_probe(),
will also call irq_domain_remove() through xgene_msi_remove() on the
same failure, which may lead to a use-after-free. Set the freed pointer
to NULL to fix this issue.

Fixes: dcd19de36775 ("PCI: xgene: Add APM X-Gene v1 PCIe MSI/MSIX termination driver")
Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
---
 drivers/pci/controller/pci-xgene-msi.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/pci/controller/pci-xgene-msi.c b/drivers/pci/controller/pci-xgene-msi.c
index 3ce38dfd0d29..c0192c5ff0f3 100644
--- a/drivers/pci/controller/pci-xgene-msi.c
+++ b/drivers/pci/controller/pci-xgene-msi.c
@@ -253,6 +253,7 @@ static int xgene_allocate_domains(struct xgene_msi *msi)
 
 	if (!msi->msi_domain) {
 		irq_domain_remove(msi->inner_domain);
+		msi->inner_domain = NULL;
 		return -ENOMEM;
 	}
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread
* [PATCH] PCI: xgene-msi: Fix a potential UAF in xgene_msi_probe
@ 2023-09-26  2:59 ` Dinghao Liu
  0 siblings, 0 replies; 12+ messages in thread
From: Dinghao Liu @ 2023-09-26  2:59 UTC (permalink / raw)
  To: dinghao.liu
  Cc: Toan Le, Lorenzo Pieralisi, Krzysztof Wilczyński,
	Rob Herring, Bjorn Helgaas, Duc Dang, Marc Zyngier,
	Tanmay Inamdar, linux-pci, linux-arm-kernel, linux-kernel

xgene_allocate_domains() will call irq_domain_remove() to free
msi->inner_domain on failure. However, its caller, xgene_msi_probe(),
will also call irq_domain_remove() through xgene_msi_remove() on the
same failure, which may lead to a use-after-free. Remove the first
irq_domain_remove() and let xgene_free_domains() cleanup domains.

Fixes: dcd19de36775 ("PCI: xgene: Add APM X-Gene v1 PCIe MSI/MSIX termination driver")
Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
---

Changelog:

v2: -Remove irq_domain_remove() instead of nulling msi_domain.
---
 drivers/pci/controller/pci-xgene-msi.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/pci/controller/pci-xgene-msi.c b/drivers/pci/controller/pci-xgene-msi.c
index 3ce38dfd0d29..0f9b9394399d 100644
--- a/drivers/pci/controller/pci-xgene-msi.c
+++ b/drivers/pci/controller/pci-xgene-msi.c
@@ -251,10 +251,8 @@ static int xgene_allocate_domains(struct xgene_msi *msi)
 						    &xgene_msi_domain_info,
 						    msi->inner_domain);
 
-	if (!msi->msi_domain) {
-		irq_domain_remove(msi->inner_domain);
+	if (!msi->msi_domain)
 		return -ENOMEM;
-	}
 
 	return 0;
 }
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2023-09-30  9:57 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-25  6:21 [PATCH] PCI: xgene-msi: Fix a potential UAF in xgene_msi_probe Dinghao Liu
2023-09-25  6:21 ` Dinghao Liu
2023-09-25  9:40 ` Marc Zyngier
2023-09-25  9:40   ` Marc Zyngier
2023-09-26  2:21   ` dinghao.liu
2023-09-26  2:21     ` dinghao.liu
  -- strict thread matches above, loose matches on Subject: below --
2023-09-26  2:59 Dinghao Liu
2023-09-26  2:59 ` Dinghao Liu
2023-09-29  9:14 ` Marc Zyngier
2023-09-29  9:14   ` Marc Zyngier
2023-09-30  9:56   ` dinghao.liu
2023-09-30  9:56     ` dinghao.liu

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.