[PATCH 1/3] PCI: apple: Fix ECAM config window use-after-free
Hongyan Xu
getshell at seu.edu.cn
Sun Nov 8 02:56:37 PST 2026
pcie-apple.c has no ->remove for pci_host_common_init(), so unbinding only
runs devres_release_all(): gen_pci_unmap_cfg() -> pci_ecam_free() frees the
ECAM config window while the bus tree stays registered - only
pci_remove_bus() unlinks a bus, and only pci_host_common_remove() reaches
it for a root bus. The next config access is a use-after-free in
pci_ecam_map_bus(), which reads cfg->ops->bus_shift.
Trigger: CONFIG_PCIE_APPLE=m; as root, one command: # rmmod apple_pcie
Fix: add .remove = pci_host_common_remove, as pci-host-generic.c does since
commit 01fcb7f777a9 ("PCI: Add support for unbinding the generic PCI host
controller"), so pci_remove_root_bus() unlinks the bus before devres frees
cfg. Scope: cfg lifetime only; its IRQ handlers stay unreleased, so the
module is still unsafe to unload.
Fixes: 1e33888fbe44 ("PCI: apple: Add initial hardware bring-up")
Cc: stable at vger.kernel.org
Signed-off-by: Hongyan Xu <getshell at seu.edu.cn>
---
drivers/pci/controller/pcie-apple.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller/pcie-apple.c
index 2d92fc79f6dd..805171551e01 100644
--- a/drivers/pci/controller/pcie-apple.c
+++ b/drivers/pci/controller/pcie-apple.c
@@ -884,6 +884,7 @@ MODULE_DEVICE_TABLE(of, apple_pcie_of_match);
static struct platform_driver apple_pcie_driver = {
.probe = apple_pcie_probe,
+ .remove = pci_host_common_remove,
.driver = {
.name = "pcie-apple",
.of_match_table = apple_pcie_of_match,
--
2.50.1.windows.1
More information about the linux-riscv
mailing list