Subject: CVE-2024-40963: mips: bmips: BCM6358: make sure CBR is correctly set

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

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

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

mips: bmips: BCM6358: make sure CBR is correctly set

It was discovered that some device have CBR address set to 0 causing
kernel panic when arch_sync_dma_for_cpu_all is called.

This was notice in situation where the system is booted from TP1 and
BMIPS_GET_CBR() returns 0 instead of a valid address and
!!(read_c0_brcm_cmt_local() & (1 << 31)); not failing.

The current check whether RAC flush should be disabled or not are not
enough hence lets check if CBR is a valid address or not.

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

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

	Issue introduced in 5.4.240 with commit d65de5ee8b72 and fixed in 5.4.279 with commit 10afe5f7d30f
	Issue introduced in 5.10.177 with commit 47a449ec09b4 and fixed in 5.10.221 with commit 36d771ce6028
	Issue introduced in 5.15.106 with commit 65b723644294 and fixed in 5.15.162 with commit 89167072fd24
	Issue introduced in 6.1.23 with commit 2cdbcff99f15 and fixed in 6.1.96 with commit 6c0f6ccd9391
	Issue introduced in 6.3 with commit ab327f8acdf8 and fixed in 6.6.36 with commit 2cd4854ef14a
	Issue introduced in 6.3 with commit ab327f8acdf8 and fixed in 6.9.7 with commit da895fd6da43
	Issue introduced in 6.3 with commit ab327f8acdf8 and fixed in 6.10 with commit ce5cdd3b0521
	Issue introduced in 6.2.10 with commit 288c96aa5b55

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-40963
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:
	arch/mips/bmips/setup.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/10afe5f7d30f6fe50c2b1177549d0e04921fc373
	https://git.kernel.org/stable/c/36d771ce6028b886e18a4a8956a5d23688e4e13d
	https://git.kernel.org/stable/c/89167072fd249e5f23ae2f8093f87da5925cef27
	https://git.kernel.org/stable/c/6c0f6ccd939166f56a904c792d7fcadae43b9085
	https://git.kernel.org/stable/c/2cd4854ef14a487bcfb76c7980675980cad27b52
	https://git.kernel.org/stable/c/da895fd6da438af8d9326b8f02d715a9c76c3b5b
	https://git.kernel.org/stable/c/ce5cdd3b05216b704a704f466fb4c2dff3778caf