Subject: CVE-2024-26975: powercap: intel_rapl: Fix a NULL pointer dereference

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

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

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

powercap: intel_rapl: Fix a NULL pointer dereference

A NULL pointer dereference is triggered when probing the MMIO RAPL
driver on platforms with CPU ID not listed in intel_rapl_common CPU
model list.

This is because the intel_rapl_common module still probes on such
platforms even if 'defaults_msr' is not set after commit 1488ac990ac8
("powercap: intel_rapl: Allow probing without CPUID match"). Thus the
MMIO RAPL rp->priv->defaults is NULL when registering to RAPL framework.

Fix the problem by adding sanity check to ensure rp->priv->rapl_defaults
is always valid.

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

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

	Issue introduced in 6.5 with commit 1488ac990ac8 and fixed in 6.6.24 with commit 0641908b906a
	Issue introduced in 6.5 with commit 1488ac990ac8 and fixed in 6.7.12 with commit 9b254feb2499
	Issue introduced in 6.5 with commit 1488ac990ac8 and fixed in 6.8.3 with commit 2f73cf2ae5e0
	Issue introduced in 6.5 with commit 1488ac990ac8 and fixed in 6.9 with commit 2d1f5006ff95

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-26975
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/powercap/intel_rapl_common.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/0641908b906a133f1494c312a71f9fecbe2b6c78
	https://git.kernel.org/stable/c/9b254feb249981b66ccdb1dae54e757789a15ba1
	https://git.kernel.org/stable/c/2f73cf2ae5e0f4e629db5be3a4380ff7807148e6
	https://git.kernel.org/stable/c/2d1f5006ff95770da502f8cee2a224a1ff83866e