Subject: CVE-2024-38556: net/mlx5: Add a timeout to acquire the command queue semaphore

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

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

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

net/mlx5: Add a timeout to acquire the command queue semaphore

Prevent forced completion handling on an entry that has not yet been
assigned an index, causing an out of bounds access on idx = -22.
Instead of waiting indefinitely for the sem, blocking flow now waits for
index to be allocated or a sem acquisition timeout before beginning the
timer for FW completion.

Kernel log example:
mlx5_core 0000:06:00.0: wait_func_handle_exec_timeout:1128:(pid 185911): cmd[-22]: CREATE_UCTX(0xa04) No done completion

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

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

	Issue introduced in 5.17 with commit 8e715cd613a1 and fixed in 6.1.93 with commit 4baae687a20e
	Issue introduced in 5.17 with commit 8e715cd613a1 and fixed in 6.6.33 with commit f9caccdd42e9
	Issue introduced in 5.17 with commit 8e715cd613a1 and fixed in 6.8.12 with commit 2d0962d05c93
	Issue introduced in 5.17 with commit 8e715cd613a1 and fixed in 6.9.3 with commit 94024332a129
	Issue introduced in 5.17 with commit 8e715cd613a1 and fixed in 6.10 with commit 485d65e13571
	Issue introduced in 5.4.174 with commit 74dd45122b84
	Issue introduced in 5.10.94 with commit e801f81cee3c
	Issue introduced in 5.15.17 with commit d73d81447c66
	Issue introduced in 5.16.3 with commit 4646175c19fd

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-38556
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/cmd.c
	include/linux/mlx5/driver.h

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/4baae687a20ef2b82fde12de3c04461e6f2521d6
	https://git.kernel.org/stable/c/f9caccdd42e999b74303c9b0643300073ed5d319
	https://git.kernel.org/stable/c/2d0962d05c93de391ce85f6e764df895f47c8918
	https://git.kernel.org/stable/c/94024332a129c6e4275569d85c0c1bfb2ae2d71b
	https://git.kernel.org/stable/c/485d65e1357123a697c591a5aeb773994b247ad7