Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

Commit

Permalink
mptcp: Avoid ever-increasing count of orphan sockets
Browse files Browse the repository at this point in the history
We have observed an ever-increasing count of orphan sockets on busy
servers. These are MPTCP-connections that ran out of MPTCP subflows.

What happens then is that when we try to retransmit the DATA_FIN, we fail in
mptcp_retransmit_skb. In that case, retrans_stamp won't be set and
remains 0.

If that happens, the check in retransmits_timed_out() may always return
false, depending on whether tcp_time_stamp(tcp_sk(sk)) is > 2^31 or not.
Meaning, we never call tcp_write_err() on that MPTCP-socket and thus it
will hang around forever.

tcp_retransmit_skb handles that by always setting retrans_stamp -
regardless of whether the retransmission succeeded or not.

We should do the same.

Fixes: Zero-day bug
Signed-off-by: Christoph Paasch <cpaasch@apple.com>
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
(cherry picked from commit 3a4382f)
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
(cherry picked from commit 95803d8)
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
  • Loading branch information
cpaasch authored and matttbe committed Jul 15, 2022
1 parent c53b72e commit 54147de
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion net/mptcp/mptcp_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -1563,7 +1563,9 @@ int mptcp_retransmit_skb(struct sock *meta_sk, struct sk_buff *skb)
*/
if (refcount_read(&meta_sk->sk_wmem_alloc) >
min(meta_sk->sk_wmem_queued + (meta_sk->sk_wmem_queued >> 2), meta_sk->sk_sndbuf)) {
return -EAGAIN;
err = -EAGAIN;

goto failed;
}

/* We need to make sure that the retransmitted segment can be sent on a
Expand Down Expand Up @@ -1626,6 +1628,12 @@ int mptcp_retransmit_skb(struct sock *meta_sk, struct sk_buff *skb)

failed:
NET_INC_STATS(sock_net(meta_sk), LINUX_MIB_TCPRETRANSFAIL);
/* Save stamp of the first attempted retransmit. */
if (!meta_tp->retrans_stamp) {
tcp_mstamp_refresh(meta_tp);
meta_tp->retrans_stamp = tcp_time_stamp(meta_tp);
}

return err;
}

Expand Down

0 comments on commit 54147de

Please sign in to comment.