Skip to content

Commit cc3c039

Browse files
matttbegregkh
authored andcommitted
mptcp: pm: ADD_ADDR rtx: fix potential data-race
commit 5cd6e0a 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: 00cfd77 ("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>
1 parent 7e61444 commit cc3c039

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

net/mptcp/pm.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,13 @@ static void mptcp_pm_add_timer(struct timer_list *timer)
350350
if (inet_sk_state_load(sk) == TCP_CLOSE)
351351
return;
352352

353+
bh_lock_sock(sk);
354+
if (sock_owned_by_user(sk)) {
355+
/* Try again later. */
356+
sk_reset_timer(sk, timer, jiffies + HZ / 20);
357+
goto out;
358+
}
359+
353360
if (mptcp_pm_should_add_signal_addr(msk)) {
354361
sk_reset_timer(sk, timer, jiffies + TCP_RTO_MAX / 8);
355362
goto out;
@@ -378,6 +385,7 @@ static void mptcp_pm_add_timer(struct timer_list *timer)
378385
mptcp_pm_subflow_established(msk);
379386

380387
out:
388+
bh_unlock_sock(sk);
381389
__sock_put(sk);
382390
}
383391

0 commit comments

Comments
 (0)