]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
mptcp: pm: ADD_ADDR rtx: fix potential data-race
authorMatthieu Baerts (NGI0) <matttbe@kernel.org>
Tue, 5 May 2026 15:00:51 +0000 (17:00 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 14 May 2026 13:31:17 +0000 (15:31 +0200)
commit 5cd6e0ad79d2615264f63929f8b457ad97ae550d upstream.

This mptcp_pm_add_timer() helper is executed as a timer callback in
softirq context. To avoid any data races, the socket lock needs to be
held with bh_lock_sock().

If the socket is in use, retry again soon after, similar to what is done
with the keepalive timer.

Fixes: 00cfd77b9063 ("mptcp: retransmit ADD_ADDR when timeout")
Cc: stable@vger.kernel.org
Reviewed-by: Mat Martineau <martineau@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Link: https://patch.msgid.link/20260505-net-mptcp-pm-fixes-7-1-rc3-v1-3-fca8091060a4@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/mptcp/pm.c

index c46b7b0ca7138035fbd43d2ccd85337a0e95eb81..24295517711b467d05af03904a5d9028f8a5454c 100644 (file)
@@ -350,6 +350,13 @@ static void mptcp_pm_add_timer(struct timer_list *timer)
        if (inet_sk_state_load(sk) == TCP_CLOSE)
                return;
 
+       bh_lock_sock(sk);
+       if (sock_owned_by_user(sk)) {
+               /* Try again later. */
+               sk_reset_timer(sk, timer, jiffies + HZ / 20);
+               goto out;
+       }
+
        if (mptcp_pm_should_add_signal_addr(msk)) {
                sk_reset_timer(sk, timer, jiffies + TCP_RTO_MAX / 8);
                goto out;
@@ -378,6 +385,7 @@ static void mptcp_pm_add_timer(struct timer_list *timer)
                mptcp_pm_subflow_established(msk);
 
 out:
+       bh_unlock_sock(sk);
        __sock_put(sk);
 }