Skip to content

Commit 1b1b43e

Browse files
Paolo Abenikuba-moo
authored andcommitted
mptcp: fix data race around msk->first access
The first subflow socket is accessed outside the msk socket lock by mptcp_subflow_fail(), we need to annotate each write access with WRITE_ONCE, but a few spots still lacks it. Fixes: 76a13b3 ("mptcp: invoke MP_FAIL response when needed") Reviewed-by: Mat Martineau <martineau@kernel.org> Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Mat Martineau <martineau@kernel.org> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 7e8b88e commit 1b1b43e

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

net/mptcp/protocol.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ static int __mptcp_socket_create(struct mptcp_sock *msk)
9090
if (err)
9191
return err;
9292

93-
msk->first = ssock->sk;
93+
WRITE_ONCE(msk->first, ssock->sk);
9494
WRITE_ONCE(msk->subflow, ssock);
9595
subflow = mptcp_subflow_ctx(ssock->sk);
9696
list_add(&subflow->node, &msk->conn_list);
@@ -2419,7 +2419,7 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk,
24192419
sock_put(ssk);
24202420

24212421
if (ssk == msk->first)
2422-
msk->first = NULL;
2422+
WRITE_ONCE(msk->first, NULL);
24232423

24242424
out:
24252425
if (ssk == msk->last_snd)
@@ -2720,7 +2720,7 @@ static int __mptcp_init_sock(struct sock *sk)
27202720
WRITE_ONCE(msk->rmem_released, 0);
27212721
msk->timer_ival = TCP_RTO_MIN;
27222722

2723-
msk->first = NULL;
2723+
WRITE_ONCE(msk->first, NULL);
27242724
inet_csk(sk)->icsk_sync_mss = mptcp_sync_mss;
27252725
WRITE_ONCE(msk->csum_enabled, mptcp_is_checksum_enabled(sock_net(sk)));
27262726
WRITE_ONCE(msk->allow_infinite_fallback, true);

0 commit comments

Comments
 (0)