From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org
Cc: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Simon Richter" <Simon.Richter@hogyros.de>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Sasha Levin" <sashal@kernel.org>
Subject: [PATCH 5.15.y 1/6] PCI: Prevent resource tree corruption when BAR resize fails
Date: Wed, 15 Jul 2026 07:16:13 -0400 [thread overview]
Message-ID: <20260715111618.647249-1-sashal@kernel.org> (raw)
In-Reply-To: <2026071314-tableware-flashback-79cc@gregkh>
From: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
[ Upstream commit 91c4c89db41499eea1b29c56655f79c3bae66e93 ]
pbus_reassign_bridge_resources() saves bridge windows into the saved
list before attempting to adjust resource assignments to perform a BAR
resize operation. If resource adjustments cannot be completed fully,
rollback is attempted by restoring the resource from the saved list.
The rollback, however, does not check whether the resources it restores were
assigned by the partial resize attempt. If restore changes addresses of the
resource, it can result in corrupting the resource tree.
An example of a corrupted resource tree with overlapping addresses:
6200000000000-6203fbfffffff : pciex@620c3c0000000
6200000000000-6203fbff0ffff : PCI Bus 0030:01
6200020000000-62000207fffff : 0030:01:00.0
6200000000000-6203fbff0ffff : PCI Bus 0030:02
A resource that are assigned into the resource tree must remain
unchanged. Thus, release such a resource before attempting to restore
and claim it back.
For simplicity, always do the release and claim back for the resource
even in the cases where it is restored to the same address range.
Note: this fix may "break" some cases where devices "worked" because
the resource tree corruption allowed address space double counting to
fit more resource than what can now be assigned without double
counting. The upcoming changes to BAR resizing should address those
scenarios (to the extent possible).
Fixes: 8bb705e3e79d ("PCI: Add pci_resize_resource() for resizing BARs")
Reported-by: Simon Richter <Simon.Richter@hogyros.de>
Link: https://lore.kernel.org/linux-pci/67840a16-99b4-4d8c-9b5c-4721ab0970a2@hogyros.de/
Reported-by: Alex Bennée <alex.bennee@linaro.org>
Link: https://lore.kernel.org/linux-pci/874irqop6b.fsf@draig.linaro.org/
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Tested-by: Alex Bennée <alex.bennee@linaro.org> # AVA, AMD GPU
Link: https://patch.msgid.link/20251113162628.5946-2-ilpo.jarvinen@linux.intel.com
Stable-dep-of: ee7471fe968d ("PCI: Skip Resizable BAR restore on read error")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/pci/setup-bus.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 04c3ae8efc0f84..92a9a0f38fa76e 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -2257,6 +2257,11 @@ int pci_reassign_bridge_resources(struct pci_dev *bridge, unsigned long type)
bridge = dev_res->dev;
i = res - bridge->resource;
+ if (res->parent) {
+ release_child_resources(res);
+ pci_release_resource(bridge, i);
+ }
+
res->start = dev_res->start;
res->end = dev_res->end;
res->flags = dev_res->flags;
--
2.53.0
next prev parent reply other threads:[~2026-07-15 11:16 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-13 13:24 FAILED: patch "[PATCH] PCI: Skip Resizable BAR restore on read error" failed to apply to 5.15-stable tree gregkh
2026-07-15 11:16 ` Sasha Levin [this message]
2026-07-15 11:16 ` [PATCH 5.15.y 2/6] PCI: Free saved list without holding pci_bus_sem Sasha Levin
2026-07-15 11:16 ` [PATCH 5.15.y 3/6] PCI: Fix restoring BARs on BAR resize rollback path Sasha Levin
2026-07-15 11:16 ` [PATCH 5.15.y 4/6] PCI: Add kerneldoc for pci_resize_resource() Sasha Levin
2026-07-15 11:16 ` [PATCH 5.15.y 5/6] PCI: Move Resizable BAR code to rebar.c Sasha Levin
2026-07-15 11:16 ` [PATCH 5.15.y 6/6] PCI: Skip Resizable BAR restore on read error Sasha Levin
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=20260715111618.647249-1-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=Simon.Richter@hogyros.de \
--cc=alex.bennee@linaro.org \
--cc=bhelgaas@google.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=stable@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox