Subject: CVE-2022-48932: net/mlx5: DR, Fix slab-out-of-bounds in mlx5_cmd_dr_create_fte

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

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

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

net/mlx5: DR, Fix slab-out-of-bounds in mlx5_cmd_dr_create_fte

When adding a rule with 32 destinations, we hit the following out-of-band
access issue:

  BUG: KASAN: slab-out-of-bounds in mlx5_cmd_dr_create_fte+0x18ee/0x1e70

This patch fixes the issue by both increasing the allocated buffers to
accommodate for the needed actions and by checking the number of actions
to prevent this issue when a rule with too many actions is provided.

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

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

	Issue introduced in 5.16 with commit 1ffd498901c1 and fixed in 5.16.12 with commit 4ad319cdfbe5
	Issue introduced in 5.16 with commit 1ffd498901c1 and fixed in 5.17 with commit 0aec12d97b20

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-48932
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/steering/fs_dr.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/4ad319cdfbe555b4ff67bc608736c46a6930c848
	https://git.kernel.org/stable/c/0aec12d97b2036af0946e3d582144739860ac07b