Subject: CVE-2024-47750: RDMA/hns: Fix Use-After-Free of rsv_qp on HIP08

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

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

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

RDMA/hns: Fix Use-After-Free of rsv_qp on HIP08

Currently rsv_qp is freed before ib_unregister_device() is called
on HIP08. During the time interval, users can still dereg MR and
rsv_qp will be used in this process, leading to a UAF. Move the
release of rsv_qp after calling ib_unregister_device() to fix it.

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

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

	Issue introduced in 5.18 with commit 70f92521584f and fixed in 6.1.113 with commit 2ccf1c75d399
	Issue introduced in 5.18 with commit 70f92521584f and fixed in 6.6.54 with commit d2d9c5127122
	Issue introduced in 5.18 with commit 70f92521584f and fixed in 6.10.13 with commit dac2723d8bfa
	Issue introduced in 5.18 with commit 70f92521584f and fixed in 6.11.2 with commit 60595923371c
	Issue introduced in 5.18 with commit 70f92521584f and fixed in 6.12-rc1 with commit fd8489294dd2

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-47750
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/infiniband/hw/hns/hns_roce_hw_v2.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/2ccf1c75d39949d8ea043d04a2e92d7100ea723d
	https://git.kernel.org/stable/c/d2d9c5127122745da6e887f451dd248cfeffca33
	https://git.kernel.org/stable/c/dac2723d8bfa9cf5333f477741e6e5fa1ed34645
	https://git.kernel.org/stable/c/60595923371c2ebe7faf82536c47eb0c967e3425
	https://git.kernel.org/stable/c/fd8489294dd2beefb70f12ec4f6132aeec61a4d0