Skip to content

Commit e19f1e3

Browse files
Qing Luogregkh
authored andcommitted
mptcp: pm: fix data race in add_addr timer callback
[ Upstream commit a7aad5b ] The timer callback reads entry->retrans_times outside pm.lock to decide whether to call mptcp_pm_subflow_established(). Since mptcp_pm_announced_del_timer() can concurrently set retrans_times = ADD_ADDR_RETRANS_MAX under pm.lock, a race condition exists. I discovered this issue while studying the code. AI tools helped me to verify the issue can potentially happen under race conditions. Use a local 'retransmit' flag set inside pm.lock to capture whether retransmission is still possible when the lock is taken. This allows to call mptcp_pm_subflow_established() accordingly, and not depending on the situation that can be different when checked outside the pm.lock. Fixes: 348d5c1 ("mptcp: move to next addr when timeout") Cc: stable@vger.kernel.org Signed-off-by: Qing Luo <luoqing@kylinos.cn> Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Link: https://patch.msgid.link/20260803-net-mptcp-misc-fixes-7-2-rc6-v2-4-b8f496d71664@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 5da972e commit e19f1e3

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

net/mptcp/pm_netlink.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ static void mptcp_pm_add_timer(struct timer_list *timer)
307307
struct mptcp_sock *msk = entry->sock;
308308
struct sock *sk = (struct sock *)msk;
309309
unsigned int timeout = 0;
310+
bool retransmit;
310311

311312
pr_debug("msk=%p\n", msk);
312313

@@ -344,12 +345,13 @@ static void mptcp_pm_add_timer(struct timer_list *timer)
344345
entry->retrans_times++;
345346
}
346347

347-
if (entry->retrans_times >= ADD_ADDR_RETRANS_MAX)
348+
retransmit = entry->retrans_times < ADD_ADDR_RETRANS_MAX;
349+
if (!retransmit)
348350
timeout = 0;
349351

350352
spin_unlock_bh(&msk->pm.lock);
351353

352-
if (entry->retrans_times == ADD_ADDR_RETRANS_MAX)
354+
if (!retransmit)
353355
mptcp_pm_subflow_established(msk);
354356

355357
out:

0 commit comments

Comments
 (0)