mptcp: move subflow cleanup in mptcp_destroy_common()
authorPaolo Abeni <pabeni@redhat.com>
Fri, 5 Aug 2022 00:21:25 +0000 (17:21 -0700)
committerDavid S. Miller <davem@davemloft.net>
Fri, 5 Aug 2022 07:51:28 +0000 (08:51 +0100)
commitc0bf3c6aa444a5ef44acc57ef6cfa53fd4fc1c9b
treee17e53860c401852e80eb815ed850436d4c7ea96
parent4ae97cae07e15d41e5c0ebabba64c6eefdeb0bbe
mptcp: move subflow cleanup in mptcp_destroy_common()

If the mptcp socket creation fails due to a CGROUP_INET_SOCK_CREATE
eBPF program, the MPTCP protocol ends-up leaking all the subflows:
the related cleanup happens in __mptcp_destroy_sock() that is not
invoked in such code path.

Address the issue moving the subflow sockets cleanup in the
mptcp_destroy_common() helper, which is invoked in every msk cleanup
path.

Additionally get rid of the intermediate list_splice_init step, which
is an unneeded relic from the past.

The issue is present since before the reported root cause commit, but
any attempt to backport the fix before that hash will require a complete
rewrite.

Fixes: e16163b6e2 ("mptcp: refactor shutdown and close")
Reported-by: Nguyen Dinh Phi <phind.uet@gmail.com>
Reviewed-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Co-developed-by: Nguyen Dinh Phi <phind.uet@gmail.com>
Signed-off-by: Nguyen Dinh Phi <phind.uet@gmail.com>
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>
net/mptcp/protocol.c
net/mptcp/protocol.h
net/mptcp/subflow.c