Subject: CVE-2021-47616: RDMA: Fix use-after-free in rxe_queue_cleanup

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

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

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

RDMA: Fix use-after-free in rxe_queue_cleanup

On error handling path in rxe_qp_from_init() qp->sq.queue is freed and
then rxe_create_qp() will drop last reference to this object. qp clean up
function will try to free this queue one time and it causes UAF bug.

Fix it by zeroing queue pointer after freeing queue in rxe_qp_from_init().

The Linux kernel CVE team has assigned CVE-2021-47616 to this issue.

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

	Issue introduced in 5.15 with commit 514aee660df4 and fixed in 5.15.10 with commit acb53e47db1f
	Issue introduced in 5.15 with commit 514aee660df4 and fixed in 5.16 with commit 84b01721e804

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-2021-47616
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/sw/rxe/rxe_qp.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/acb53e47db1fbc7cd37ab10b46388f045a76e383
	https://git.kernel.org/stable/c/84b01721e8042cdd1e8ffeb648844a09cd4213e0