Subject: CVE-2024-45009: mptcp: pm: only decrement add_addr_accepted for MPJ req

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

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

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

mptcp: pm: only decrement add_addr_accepted for MPJ req

Adding the following warning ...

  WARN_ON_ONCE(msk->pm.add_addr_accepted == 0)

... before decrementing the add_addr_accepted counter helped to find a
bug when running the "remove single subflow" subtest from the
mptcp_join.sh selftest.

Removing a 'subflow' endpoint will first trigger a RM_ADDR, then the
subflow closure. Before this patch, and upon the reception of the
RM_ADDR, the other peer will then try to decrement this
add_addr_accepted. That's not correct because the attached subflows have
not been created upon the reception of an ADD_ADDR.

A way to solve that is to decrement the counter only if the attached
subflow was an MP_JOIN to a remote id that was not 0, and initiated by
the host receiving the RM_ADDR.

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

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

	Issue introduced in 5.10 with commit d0876b2284cf and fixed in 5.15.167 with commit 35b31f5549ed
	Issue introduced in 5.10 with commit d0876b2284cf and fixed in 6.1.107 with commit 85b866e4c4e6
	Issue introduced in 5.10 with commit d0876b2284cf and fixed in 6.6.48 with commit d20bf2c96d7f
	Issue introduced in 5.10 with commit d0876b2284cf and fixed in 6.10.7 with commit 2060f1efab37
	Issue introduced in 5.10 with commit d0876b2284cf and fixed in 6.11 with commit 1c1f72137598

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-45009
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:
	net/mptcp/pm_netlink.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/35b31f5549ede4070566b949781e83495906b43d
	https://git.kernel.org/stable/c/85b866e4c4e63a1d7afb58f1e24273caad03d0b7
	https://git.kernel.org/stable/c/d20bf2c96d7ffd171299b32f562f70e5bf5dc608
	https://git.kernel.org/stable/c/2060f1efab370b496c4903b840844ecaff324c3c
	https://git.kernel.org/stable/c/1c1f721375989579e46741f59523e39ec9b2a9bd