From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1011A3D6CD9; Tue, 21 Jul 2026 22:58:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784674682; cv=none; b=i5w5y7ZUkNtDbqbG0/n8hz2quYCcLDAZmQxhtpQb6SY7Ez3FTitnNLSpSxtda88nxqbT57Uo7E2J6q/c8X67EB2wBIfd0Ln2IAMb3AuTno/U7QEPS55WyK5IN6Ge0Hh6alu5FtvFgB6/zrAv0juFll6SewWIGdGr176QDio0ytw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784674682; c=relaxed/simple; bh=w5QPs7s4KWrpsudZrqfhhXO18J4HUiDgWaKoQgAtf6g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TkXf2RXG5rqj1V6Yw359z5xXrd4zJNpF+53taSvaPLtPgG3R/GVze6pQ+kShE04Cmin2ApXpviS/zCB+sQVwsKCtDR9MF4vkPil4QTBzhL6MeeopaJ+QDocmLTL7GcE/vYVt/I3CtZG2G2lYjCYWbTh6uBUYXZAqIWRM/a1C104= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=FbDvE1NS; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="FbDvE1NS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 25F551F000E9; Tue, 21 Jul 2026 22:57:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784674679; bh=0nGXEweFMSAOXiYuAdu94gyqBGYW11piGyv9P0JOW4k=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=FbDvE1NSIGwUStGN7hIlqG+nDhtiCEw99ooAPjsdBocEblEfX+NbkxCjNOAUWSeT/ CcMlgHNk2mftn/m0dyUzCY5UweqB49NKdNSjRm0S4c1wICUbtDp3K7YbiWYv95q6Cy igytJpq8kejycQNKbELqif06p5+2CcHyLBuPN97o= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Simon Richter , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Bjorn Helgaas , Sasha Levin Subject: [PATCH 5.10 630/699] PCI: Prevent resource tree corruption when BAR resize fails Date: Tue, 21 Jul 2026 17:26:29 +0200 Message-ID: <20260721152409.958030192@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152355.667394603@linuxfoundation.org> References: <20260721152355.667394603@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ilpo Järvinen [ 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 Link: https://lore.kernel.org/linux-pci/67840a16-99b4-4d8c-9b5c-4721ab0970a2@hogyros.de/ Reported-by: Alex Bennée Link: https://lore.kernel.org/linux-pci/874irqop6b.fsf@draig.linaro.org/ Signed-off-by: Ilpo Järvinen Signed-off-by: Bjorn Helgaas Tested-by: Alex Bennée # 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 Signed-off-by: Greg Kroah-Hartman --- drivers/pci/setup-bus.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -2257,6 +2257,11 @@ cleanup: 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;