Subject: CVE-2024-46737: nvmet-tcp: fix kernel crash if commands allocation fails

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

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

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

nvmet-tcp: fix kernel crash if commands allocation fails

If the commands allocation fails in nvmet_tcp_alloc_cmds()
the kernel crashes in nvmet_tcp_release_queue_work() because of
a NULL pointer dereference.

  nvmet: failed to install queue 0 cntlid 1 ret 6
  Unable to handle kernel NULL pointer dereference at
         virtual address 0000000000000008

Fix the bug by setting queue->nr_cmds to zero in case
nvmet_tcp_alloc_cmd() fails.

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

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

	Issue introduced in 5.0 with commit 872d26a391da and fixed in 5.4.284 with commit 03e1fd0327fa
	Issue introduced in 5.0 with commit 872d26a391da and fixed in 5.10.226 with commit 50632b877ce5
	Issue introduced in 5.0 with commit 872d26a391da and fixed in 5.15.167 with commit 91dad30c5607
	Issue introduced in 5.0 with commit 872d26a391da and fixed in 6.1.110 with commit 7957c731fc2b
	Issue introduced in 5.0 with commit 872d26a391da and fixed in 6.6.51 with commit 489f2913a63f
	Issue introduced in 5.0 with commit 872d26a391da and fixed in 6.10.10 with commit 6c04d1e3ab22
	Issue introduced in 5.0 with commit 872d26a391da and fixed in 6.11 with commit 5572a55a6f83

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-46737
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/nvme/target/tcp.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/03e1fd0327fa5e2174567f5fe9290fe21d21b8f4
	https://git.kernel.org/stable/c/50632b877ce55356f5d276b9add289b1e7ddc683
	https://git.kernel.org/stable/c/91dad30c5607e62864f888e735d0965567827bdf
	https://git.kernel.org/stable/c/7957c731fc2b23312f8935812dee5a0b14b04e2d
	https://git.kernel.org/stable/c/489f2913a63f528cfe3f21722583fb981967ecda
	https://git.kernel.org/stable/c/6c04d1e3ab22cc5394ef656429638a5947f87244
	https://git.kernel.org/stable/c/5572a55a6f830ee3f3a994b6b962a5c327d28cb3