mptcp: properly account bulk freed memory
authorPaolo Abeni <pabeni@redhat.com>
Sat, 10 Jul 2021 00:20:51 +0000 (17:20 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 28 Jul 2021 12:37:23 +0000 (14:37 +0200)
commitb2fe6fc671eaef878fbe00712d5ab32ac2dd9bec
tree7c3386067c1d4dc71148cbe903d0ca3c66e694db
parentcd7f1414f17072e9c267ee37013ba38446ee0ab7
mptcp: properly account bulk freed memory

[ Upstream commit ce599c516386f09ca30848a1a4eb93d3fffbe187 ]

After commit 879526030c8b ("mptcp: protect the rx path with
the msk socket spinlock") the rmem currently used by a given
msk is really sk_rmem_alloc - rmem_released.

The safety check in mptcp_data_ready() does not take the above
in due account, as a result legit incoming data is kept in
subflow receive queue with no reason, delaying or blocking
MPTCP-level ack generation.

This change addresses the issue introducing a new helper to fetch
the rmem memory and using it as needed. Additionally add a MIB
counter for the exceptional event described above - the peer is
misbehaving.

Finally, introduce the required annotation when rmem_released is
updated.

Fixes: 879526030c8b ("mptcp: protect the rx path with the msk socket spinlock")
Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/211
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/mptcp/mib.c
net/mptcp/mib.h
net/mptcp/protocol.c
net/mptcp/protocol.h