Subject: CVE-2022-48672: of: fdt: fix off-by-one error in unflatten_dt_nodes()

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

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

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

of: fdt: fix off-by-one error in unflatten_dt_nodes()

Commit 78c44d910d3e ("drivers/of: Fix depth when unflattening devicetree")
forgot to fix up the depth check in the loop body in unflatten_dt_nodes()
which makes it possible to overflow the nps[] buffer...

Found by Linux Verification Center (linuxtesting.org) with the SVACE static
analysis tool.

The Linux kernel CVE team has assigned CVE-2022-48672 to this issue.

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

	Issue introduced in 4.7 with commit 78c44d910d3e and fixed in 4.14.295 with commit cbdda20ce363
	Issue introduced in 4.7 with commit 78c44d910d3e and fixed in 4.19.260 with commit 2566706ac639
	Issue introduced in 4.7 with commit 78c44d910d3e and fixed in 5.4.215 with commit e0e88c25f88b
	Issue introduced in 4.7 with commit 78c44d910d3e and fixed in 5.10.145 with commit ee4369260e77
	Issue introduced in 4.7 with commit 78c44d910d3e and fixed in 5.15.70 with commit ba6b9f7cc110
	Issue introduced in 4.7 with commit 78c44d910d3e and fixed in 5.19.11 with commit 2133f4513116
	Issue introduced in 4.7 with commit 78c44d910d3e and fixed in 6.0 with commit 2f945a792f67

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-2022-48672
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/of/fdt.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/cbdda20ce363356698835185801a58a28f644853
	https://git.kernel.org/stable/c/2566706ac6393386a4e7c4ce23fe17f4c98d9aa0
	https://git.kernel.org/stable/c/e0e88c25f88b9805572263c9ed20f1d88742feaf
	https://git.kernel.org/stable/c/ee4369260e77821602102dcc7d792de39a56365c
	https://git.kernel.org/stable/c/ba6b9f7cc1108bad6e2c53b1d6e0156379188db7
	https://git.kernel.org/stable/c/2133f451311671c7c42b5640d2b999326b39aa0e
	https://git.kernel.org/stable/c/2f945a792f67815abca26fa8a5e863ccf3fa1181