Subject: CVE-2024-41084: cxl/region: Avoid null pointer dereference in region lookup

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

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

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

cxl/region: Avoid null pointer dereference in region lookup

cxl_dpa_to_region() looks up a region based on a memdev and DPA.
It wrongly assumes an endpoint found mapping the DPA is also of
a fully assembled region. When not true it leads to a null pointer
dereference looking up the region name.

This appears during testing of region lookup after a failure to
assemble a BIOS defined region or if the lookup raced with the
assembly of the BIOS defined region.

Failure to clean up BIOS defined regions that fail assembly is an
issue in itself and a fix to that problem will alleviate some of
the impact. It will not alleviate the race condition so let's harden
this path.

The behavior change is that the kernel oops due to a null pointer
dereference is replaced with a dev_dbg() message noting that an
endpoint was mapped.

Additional comments are added so that future users of this function
can more clearly understand what it provides.

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

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

	Issue introduced in 6.4 with commit 0a105ab28a4d and fixed in 6.6.37 with commit a9e099e29e92
	Issue introduced in 6.4 with commit 0a105ab28a4d and fixed in 6.9.8 with commit b8a40a6dbfb0
	Issue introduced in 6.4 with commit 0a105ab28a4d and fixed in 6.10 with commit 285f2a088414

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-41084
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/cxl/core/region.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/a9e099e29e925f8b31cfe53e8a786b9796f8e453
	https://git.kernel.org/stable/c/b8a40a6dbfb0150c1081384caa9bbe28ce5d5060
	https://git.kernel.org/stable/c/285f2a08841432fc3e498b1cd00cce5216cdf189