Skip to content

Commit 27b0e70

Browse files
Paolo Abenikuba-moo
authored andcommitted
mptcp: drop bogus optimization in __mptcp_check_push()
Accessing the transmit queue without owning the msk socket lock is inherently racy, hence __mptcp_check_push() could actually quit early even when there is pending data. That in turn could cause unexpected tx lock and timeout. Dropping the early check avoids the race, implicitly relaying on later tests under the relevant lock. With such change, all the other mptcp_send_head() call sites are now under the msk socket lock and we can additionally drop the now unneeded annotation on the transmit head pointer accesses. Fixes: 6e628cd ("mptcp: use mptcp release_cb for delayed tasks") Cc: stable@vger.kernel.org Signed-off-by: Paolo Abeni <pabeni@redhat.com> Reviewed-by: Geliang Tang <geliang@kernel.org> Tested-by: Geliang Tang <geliang@kernel.org> Reviewed-by: Mat Martineau <martineau@kernel.org> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Link: https://patch.msgid.link/20251028-net-mptcp-send-timeout-v1-1-38ffff5a9ec8@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 00764aa commit 27b0e70

2 files changed

Lines changed: 5 additions & 8 deletions

File tree

net/mptcp/protocol.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,7 +1007,7 @@ static void __mptcp_clean_una(struct sock *sk)
10071007
if (WARN_ON_ONCE(!msk->recovery))
10081008
break;
10091009

1010-
WRITE_ONCE(msk->first_pending, mptcp_send_next(sk));
1010+
msk->first_pending = mptcp_send_next(sk);
10111011
}
10121012

10131013
dfrag_clear(sk, dfrag);
@@ -1552,7 +1552,7 @@ static int __subflow_push_pending(struct sock *sk, struct sock *ssk,
15521552

15531553
mptcp_update_post_push(msk, dfrag, ret);
15541554
}
1555-
WRITE_ONCE(msk->first_pending, mptcp_send_next(sk));
1555+
msk->first_pending = mptcp_send_next(sk);
15561556

15571557
if (msk->snd_burst <= 0 ||
15581558
!sk_stream_memory_free(ssk) ||
@@ -1912,7 +1912,7 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
19121912
get_page(dfrag->page);
19131913
list_add_tail(&dfrag->list, &msk->rtx_queue);
19141914
if (!msk->first_pending)
1915-
WRITE_ONCE(msk->first_pending, dfrag);
1915+
msk->first_pending = dfrag;
19161916
}
19171917
pr_debug("msk=%p dfrag at seq=%llu len=%u sent=%u new=%d\n", msk,
19181918
dfrag->data_seq, dfrag->data_len, dfrag->already_sent,
@@ -2882,7 +2882,7 @@ static void __mptcp_clear_xmit(struct sock *sk)
28822882
struct mptcp_sock *msk = mptcp_sk(sk);
28832883
struct mptcp_data_frag *dtmp, *dfrag;
28842884

2885-
WRITE_ONCE(msk->first_pending, NULL);
2885+
msk->first_pending = NULL;
28862886
list_for_each_entry_safe(dfrag, dtmp, &msk->rtx_queue, list)
28872887
dfrag_clear(sk, dfrag);
28882888
}
@@ -3422,9 +3422,6 @@ void __mptcp_data_acked(struct sock *sk)
34223422

34233423
void __mptcp_check_push(struct sock *sk, struct sock *ssk)
34243424
{
3425-
if (!mptcp_send_head(sk))
3426-
return;
3427-
34283425
if (!sock_owned_by_user(sk))
34293426
__mptcp_subflow_push_pending(sk, ssk, false);
34303427
else

net/mptcp/protocol.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ static inline struct mptcp_data_frag *mptcp_send_head(const struct sock *sk)
414414
{
415415
const struct mptcp_sock *msk = mptcp_sk(sk);
416416

417-
return READ_ONCE(msk->first_pending);
417+
return msk->first_pending;
418418
}
419419

420420
static inline struct mptcp_data_frag *mptcp_send_next(struct sock *sk)

0 commit comments

Comments
 (0)