From nobody Mon Feb 9 04:14:06 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (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 B7B2234DB67; Tue, 28 Oct 2025 17:38:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.8 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761673089; cv=none; b=SsU3NT6SviTJiWx8P4UpicNaqbAGTukp98c+ealmXi/3+B9BXYwjfViOcKAYOzp1qV7ZQDRMWlosedTC9qurZtPUJH20nkfBQ/3YFkphVj6Cjy4A5zqTeubrA/cu1XJ110q1fZzkDgEv3pn8dGmyFRYOZW5mlwGrde5c46dDKbA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761673089; c=relaxed/simple; bh=rj0qgordGZNB+YdPjKDmtqTEG5yrczqeTMJCDVNmgm0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=Ei4vc9CWr7GgqRO/uudFvjLGS5AKllW9+4sG78GiLQh9NktFCvDe6ySqLqWtga5aJcmHFf5rBZXUNpGaDbaIiGZ22Zzxvi5dS1W5SWJFzDAcJNA76uPC0jHV31EcXgQzyh+OpaifDX6FpqRzLHgU0g10SSUlQvToBUkKoo3rI3M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=lKlO0SE+; arc=none smtp.client-ip=192.198.163.8 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="lKlO0SE+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1761673084; x=1793209084; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=rj0qgordGZNB+YdPjKDmtqTEG5yrczqeTMJCDVNmgm0=; b=lKlO0SE+ySQt2SnEVkSpwL2LALVyugAxRv2/9pwjSnMTVSJWjZkOjGHL fRvYSBMeH/p1gMFr9xYxxqHcmefiuZLap+9EZGCSsa6WXYmoq/j6VZePF /BpL7smY44giXGfWsGcZNcWLbfFpd4t92W0Gmb+hfg2p1cZe18CUbFpN5 B/HumSTNcSiZqoQTBKS7v2cq194/r7gYratyi/mIfw/1tTYrJhuk357rS SG6dR0q+utO2IJt+2ce8IgBzZT0DANM2KeZ/hL0RTKKkw74CDmlT+h8Eq UMXUF5JG0hNSJkQH9VELC8d4Mvb152vVifwibKfnbmaJ5SaNzmdAlSktT A==; X-CSE-ConnectionGUID: h944opP6S4mbbmHZ658q5w== X-CSE-MsgGUID: QQSBrH6aTiGa0JCUHlWjvg== X-IronPort-AV: E=McAfee;i="6800,10657,11586"; a="81413276" X-IronPort-AV: E=Sophos;i="6.19,261,1754982000"; d="scan'208";a="81413276" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Oct 2025 10:38:03 -0700 X-CSE-ConnectionGUID: CNDiVW/JRC2hDk9azTLjtQ== X-CSE-MsgGUID: jG6aT9CEQn60hVk9anqSKQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,261,1754982000"; d="scan'208";a="185304310" Received: from ijarvine-mobl1.ger.corp.intel.com (HELO localhost) ([10.245.244.182]) by fmviesa006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Oct 2025 10:37:56 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Simon Richter , Lucas De Marchi , Alex Deucher , amd-gfx@lists.freedesktop.org, Bjorn Helgaas , David Airlie , dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org, Jani Nikula , Joonas Lahtinen , linux-pci@vger.kernel.org, Rodrigo Vivi , Simona Vetter , Tvrtko Ursulin , =?UTF-8?q?Christian=20K=C3=B6nig?= , =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= , =?UTF-8?q?Micha=C5=82=20Winiarski?= , linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH 9/9] PCI: Prevent restoring assigned resources Date: Tue, 28 Oct 2025 19:35:51 +0200 Message-Id: <20251028173551.22578-10-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251028173551.22578-1-ilpo.jarvinen@linux.intel.com> References: <20251028173551.22578-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable restore_dev_resource() copies saved addresses and flags from the struct pci_dev_resource back to the struct resource, typically, during rollback from a failure or in preparation for a retry attempt. If the resource is within resource tree, the resource must not be modified as the resource tree could be corrupted. Thus, it's a bug to call restore_dev_resource() for assigned resources (which did happen due to logic flaws in the BAR resize rollback). Add WARN_ON_ONCE() into restore_dev_resource() to detect such bugs easily and return without altering the resource to prevent corruption. Signed-off-by: Ilpo J=C3=A4rvinen --- drivers/pci/setup-bus.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 8da83b612c59..28d6ae822c0b 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -15,6 +15,7 @@ */ =20 #include +#include #include #include #include @@ -135,6 +136,9 @@ static void restore_dev_resource(struct pci_dev_resourc= e *dev_res) { struct resource *res =3D dev_res->res; =20 + if (WARN_ON_ONCE(res->parent)) + return; + res->start =3D dev_res->start; res->end =3D dev_res->end; res->flags =3D dev_res->flags; --=20 2.39.5