Subject: CVE-2024-47695: RDMA/rtrs-clt: Reset cid to con_num - 1 to stay in bounds

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

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

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

RDMA/rtrs-clt: Reset cid to con_num - 1 to stay in bounds

In the function init_conns(), after the create_con() and create_cm() for
loop if something fails. In the cleanup for loop after the destroy tag, we
access out of bound memory because cid is set to clt_path->s.con_num.

This commits resets the cid to clt_path->s.con_num - 1, to stay in bounds
in the cleanup loop later.

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

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

	Issue introduced in 5.8 with commit 6a98d71daea1 and fixed in 5.15.168 with commit 0429a4e97208
	Issue introduced in 5.8 with commit 6a98d71daea1 and fixed in 6.1.113 with commit 5ac73f8191f3
	Issue introduced in 5.8 with commit 6a98d71daea1 and fixed in 6.6.54 with commit 01b9be936ee8
	Issue introduced in 5.8 with commit 6a98d71daea1 and fixed in 6.10.13 with commit 1c50e0265fa3
	Issue introduced in 5.8 with commit 6a98d71daea1 and fixed in 6.11.2 with commit c8b7f3d9fada
	Issue introduced in 5.8 with commit 6a98d71daea1 and fixed in 6.12-rc1 with commit 3e4289b29e21

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-47695
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/ulp/rtrs/rtrs-clt.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/0429a4e972082e3a2351da414b1c017daaf8aed2
	https://git.kernel.org/stable/c/5ac73f8191f3de41fef4f934d84d97f3aadb301f
	https://git.kernel.org/stable/c/01b9be936ee8839ab9f83a7e84ee02ac6c8303c4
	https://git.kernel.org/stable/c/1c50e0265fa332c94a4a182e4efa0fc70d8fad94
	https://git.kernel.org/stable/c/c8b7f3d9fada0d4b4b7db86bf7345cd61f1d972e
	https://git.kernel.org/stable/c/3e4289b29e216a55d08a89e126bc0b37cbad9f38