Subject: CVE-2023-52645: pmdomain: mediatek: fix race conditions with genpd

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

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

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

pmdomain: mediatek: fix race conditions with genpd

If the power domains are registered first with genpd and *after that*
the driver attempts to power them on in the probe sequence, then it is
possible that a race condition occurs if genpd tries to power them on
in the same time.
The same is valid for powering them off before unregistering them
from genpd.
Attempt to fix race conditions by first removing the domains from genpd
and *after that* powering down domains.
Also first power up the domains and *after that* register them
to genpd.

The Linux kernel CVE team has assigned CVE-2023-52645 to this issue.

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

	Issue introduced in 5.11 with commit 59b644b01cf4 and fixed in 5.15.150 with commit 475426ad1ae0
	Issue introduced in 5.11 with commit 59b644b01cf4 and fixed in 6.1.80 with commit 339ddc983bc1
	Issue introduced in 5.11 with commit 59b644b01cf4 and fixed in 6.6.18 with commit f83b9abee9fa
	Issue introduced in 5.11 with commit 59b644b01cf4 and fixed in 6.7.6 with commit 3cd1d92ee1db
	Issue introduced in 5.11 with commit 59b644b01cf4 and fixed in 6.8 with commit c41336f4d690

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-2023-52645
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/pmdomain/mediatek/mtk-pm-domains.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/475426ad1ae0bfdfd8f160ed9750903799392438
	https://git.kernel.org/stable/c/339ddc983bc1622341d95f244c361cda3da3a4ff
	https://git.kernel.org/stable/c/f83b9abee9faa4868a6fac4669b86f4c215dae25
	https://git.kernel.org/stable/c/3cd1d92ee1dbf3e8f988767eb75f26207397792b
	https://git.kernel.org/stable/c/c41336f4d69057cbf88fed47951379b384540df5