Subject: CVE-2024-40940: net/mlx5: Fix tainted pointer delete is case of flow rules creation fail

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

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

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

net/mlx5: Fix tainted pointer delete is case of flow rules creation fail

In case of flow rule creation fail in mlx5_lag_create_port_sel_table(),
instead of previously created rules, the tainted pointer is deleted
deveral times.
Fix this bug by using correct flow rules pointers.

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

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

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

	Issue introduced in 5.19 with commit 352899f384d4 and fixed in 6.1.95 with commit 531eab2da27d
	Issue introduced in 5.19 with commit 352899f384d4 and fixed in 6.6.35 with commit d857df86837a
	Issue introduced in 5.19 with commit 352899f384d4 and fixed in 6.9.6 with commit a03a3fa12769
	Issue introduced in 5.19 with commit 352899f384d4 and fixed in 6.10 with commit 229bedbf62b1

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-40940
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/mellanox/mlx5/core/lag/port_sel.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/531eab2da27dd42d68dfb841d82e987f4a6738b8
	https://git.kernel.org/stable/c/d857df86837ac1c30592e8a068204d16feac9930
	https://git.kernel.org/stable/c/a03a3fa12769e25f4385bee587afe1445aee7f7a
	https://git.kernel.org/stable/c/229bedbf62b13af5aba6525ad10b62ad38d9ccb5