Subject: CVE-2024-26918: PCI: Fix active state requirement in PME polling

From: Greg Kroah-Hartman <[email-masked]>

Description
===========

In the Linux kernel, the following vulnerability has been resolved:

PCI: Fix active state requirement in PME polling

The commit noted in fixes added a bogus requirement that runtime PM managed
devices need to be in the RPM_ACTIVE state for PME polling.  In fact, only
devices in low power states should be polled.

However there's still a requirement that the device config space must be
accessible, which has implications for both the current state of the polled
device and the parent bridge, when present.  It's not sufficient to assume
the bridge remains in D0 and cases have been observed where the bridge
passes the D0 test, but the PM state indicates RPM_SUSPENDING and config
space of the polled device becomes inaccessible during pci_pme_wakeup().

Therefore, since the bridge is already effectively required to be in the
RPM_ACTIVE state, formalize this in the code and elevate the PM usage count
to maintain the state while polling the subordinate device.

This resolves a regression reported in the bugzilla below where a
Thunderbolt/USB4 hierarchy fails to scan for an attached NVMe endpoint
downstream of a bridge in a D3hot power state.

The Linux kernel CVE team has assigned CVE-2024-26918 to this issue.

Affected and fixed versions
===========================

	Issue introduced in 6.6 with commit d3fcd7360338 and fixed in 6.6.18 with commit 63b1a3d9dd3b
	Issue introduced in 6.6 with commit d3fcd7360338 and fixed in 6.7.6 with commit a4f12e5cbac2
	Issue introduced in 6.6 with commit d3fcd7360338 and fixed in 6.8 with commit 41044d536068

Please see https://www.kernel.org for a full list of currently supported
kernel versions by the kernel community.

Unaffected versions might change over time as fixes are backported to
older supported kernel versions.  The official CVE entry at
	https://cve.org/CVERecord/?id=CVE-2024-26918
will be updated if fixes are backported, please check that for the most
up to date information about this issue.

Affected files
==============

The file(s) affected by this issue are:
	drivers/pci/pci.c

Mitigation
==========

The Linux kernel CVE team recommends that you update to the latest
stable kernel version for this, and many other bugfixes.  Individual
changes are never tested alone, but rather are part of a larger kernel
release.  Cherry-picking individual commits is not recommended or
supported by the Linux kernel community at all.  If however, updating to
the latest release is impossible, the individual changes to resolve this
issue can be found at these commits:
	https://git.kernel.org/stable/c/63b1a3d9dd3b3f6d67f524e76270e66767090583
	https://git.kernel.org/stable/c/a4f12e5cbac2865c151d1e97e36eb24205afb23b
	https://git.kernel.org/stable/c/41044d5360685e78a869d40a168491a70cdb7e73