Subject: CVE-2024-43860: remoteproc: imx_rproc: Skip over memory region when node value is NULL

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

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

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

remoteproc: imx_rproc: Skip over memory region when node value is NULL

In imx_rproc_addr_init() "nph = of_count_phandle_with_args()" just counts
number of phandles. But phandles may be empty. So of_parse_phandle() in
the parsing loop (0 < a < nph) may return NULL which is later dereferenced.
Adjust this issue by adding NULL-return check.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

[Fixed title to fit within the prescribed 70-75 charcters]

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

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

	Issue introduced in 4.14 with commit a0ff4aa6f010 and fixed in 4.19.320 with commit 6884fd0283e0
	Issue introduced in 4.14 with commit a0ff4aa6f010 and fixed in 5.4.282 with commit 84beb7738459
	Issue introduced in 4.14 with commit a0ff4aa6f010 and fixed in 5.10.224 with commit 6b50462b473f
	Issue introduced in 4.14 with commit a0ff4aa6f010 and fixed in 5.15.165 with commit 4e13b7c23988
	Issue introduced in 4.14 with commit a0ff4aa6f010 and fixed in 6.1.103 with commit 9a17cf8b2ce4
	Issue introduced in 4.14 with commit a0ff4aa6f010 and fixed in 6.6.44 with commit 6c9ea3547fad
	Issue introduced in 4.14 with commit a0ff4aa6f010 and fixed in 6.10.3 with commit c877a5f5268d
	Issue introduced in 4.14 with commit a0ff4aa6f010 and fixed in 6.11 with commit 2fa26ca8b786

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-43860
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/remoteproc/imx_rproc.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/6884fd0283e0831be153fb8d82d9eda8a55acaaa
	https://git.kernel.org/stable/c/84beb7738459cac0ff9f8a7c4654b8ff82a702c0
	https://git.kernel.org/stable/c/6b50462b473fdccdc0dfad73001147e40ff19a66
	https://git.kernel.org/stable/c/4e13b7c23988c0a13fdca92e94296a3bc2ff9f21
	https://git.kernel.org/stable/c/9a17cf8b2ce483fa75258bc2cdcf628f24bcf5f8
	https://git.kernel.org/stable/c/6c9ea3547fad252fe9ae5d3ed7e066e2085bf3a2
	https://git.kernel.org/stable/c/c877a5f5268d4ab8224b9c9fbce3d746e4e72bc9
	https://git.kernel.org/stable/c/2fa26ca8b786888673689ccc9da6094150939982