Subject: CVE-2024-26723: lan966x: Fix crash when adding interface under a lag

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

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

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

lan966x: Fix crash when adding interface under a lag

There is a crash when adding one of the lan966x interfaces under a lag
interface. The issue can be reproduced like this:
ip link add name bond0 type bond miimon 100 mode balance-xor
ip link set dev eth0 master bond0

The reason is because when adding a interface under the lag it would go
through all the ports and try to figure out which other ports are under
that lag interface. And the issue is that lan966x can have ports that are
NULL pointer as they are not probed. So then iterating over these ports
it would just crash as they are NULL pointers.
The fix consists in actually checking for NULL pointers before accessing
something from the ports. Like we do in other places.

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

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

	Issue introduced in 6.1 with commit cabc9d49333d and fixed in 6.1.79 with commit b9357489c46c
	Issue introduced in 6.1 with commit cabc9d49333d and fixed in 6.6.18 with commit 48fae67d8374
	Issue introduced in 6.1 with commit cabc9d49333d and fixed in 6.7.6 with commit 2a492f01228b
	Issue introduced in 6.1 with commit cabc9d49333d and fixed in 6.8 with commit 15faa1f67ab4

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-26723
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/net/ethernet/microchip/lan966x/lan966x_lag.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/b9357489c46c7a43999964628db8b47d3a1f8672
	https://git.kernel.org/stable/c/48fae67d837488c87379f0c9f27df7391718477c
	https://git.kernel.org/stable/c/2a492f01228b7d091dfe38974ef40dccf8f9f2f1
	https://git.kernel.org/stable/c/15faa1f67ab405d47789d4702f587ec7df7ef03e