Skip to contentSkip to conversation

mptcp: prevent race between disconnect() and rtx

PATCH Applied Matthieu Baerts (NGI0) 2 participants 2 messages Oct 5 – Oct 6

Subsystems (2)
lore
Share & tools
lore

Matthieu Baerts (NGI0)

author maintainer
#0 lore raw

PATCH 1/1 mptcp: prevent race between disconnect() and rtx

From: Paolo Abeni <[email protected]>

[ Upstream commit 85c580b0d8590520ae00a15c29e9fb9c99427a3e ]

Sashiko noted that the two event can race, leading to inconsistent status. Prevent the race using the synchronous timer stop operation.

[ No conflicts, but reset msk->timer_ival to TCP_RTO_MIN: in this kernel
version, icsk->icsk_rto_min is not initialised, because this version doesn't contain commit ea4eb2adb0d3 ("mptcp: honour configured min/max RTO in retransmit paths"). Use TCP_RTO_MIN, similar to how msk->timer_ival is reset in __mptcp_init_sock() in this version. ]

---
 net/mptcp/protocol.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
net/mptcp/protocol.c +8 -2
index 7a64223c3884..da774b1a9460 100644
@@ -3367,6 +3367,7 @@ static void mptcp_copy_inaddrs(struct sock *msk, const struct sock *ssk)
 
 static int mptcp_disconnect(struct sock *sk, int flags)
 {
+	struct inet_connection_sock *icsk = inet_csk(sk);
 	struct mptcp_sock *msk = mptcp_sk(sk);
 
 	/* We are on the fastopen error path. We can't call straight into the
@@ -3379,8 +3380,13 @@ static int mptcp_disconnect(struct sock *sk, int flags)
 	mptcp_check_listen_stop(sk);
 	mptcp_set_state(sk, TCP_CLOSE);
 
-	mptcp_stop_rtx_timer(sk);
-	mptcp_stop_tout_timer(sk);
+	/* The later subflow close can not kick again the tout timer,
+	 * as the msk is already in closed status.
+	 */
+	msk->timer_ival = TCP_RTO_MIN;
+	sk_stop_timer_sync(sk, &sk->mptcp_retransmit_timer);
+	icsk->icsk_mtup.probe_timestamp = 0;
+	sk_stop_timer_sync(sk, &icsk->mptcp_tout_timer);
 
 	if (msk->token)
 		mptcp_event(MPTCP_EVENT_CLOSED, msk, NULL, GFP_KERNEL);
Signature · 1 line
2.55.0
maintainer Applied
#1 lore raw
Quoted 2 lines

[ No conflicts, but reset msk->timer_ival to TCP_RTO_MIN: in this kernel
version, icsk->icsk_rto_min is not initialised, because this version

Queued for 6.12, thanks.

Signature · 2 lines
Thanks,
Sasha