Skip to content

Commit

Permalink
mptcp: Consistently use READ_ONCE/WRITE_ONCE with msk->ack_seq
Browse files Browse the repository at this point in the history
The msk->ack_seq value is sometimes read without the msk lock held, so
make proper use of READ_ONCE and WRITE_ONCE.

Signed-off-by: Mat Martineau <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
mjmartineau authored and davem330 committed Sep 30, 2020
1 parent 4972c6c commit 917944d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions net/mptcp/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -518,11 +518,11 @@ static bool mptcp_established_options_dss(struct sock *sk, struct sk_buff *skb,

if (subflow->use_64bit_ack) {
ack_size = TCPOLEN_MPTCP_DSS_ACK64;
opts->ext_copy.data_ack = msk->ack_seq;
opts->ext_copy.data_ack = READ_ONCE(msk->ack_seq);
opts->ext_copy.ack64 = 1;
} else {
ack_size = TCPOLEN_MPTCP_DSS_ACK32;
opts->ext_copy.data_ack32 = (uint32_t)(msk->ack_seq);
opts->ext_copy.data_ack32 = (uint32_t)READ_ONCE(msk->ack_seq);
opts->ext_copy.ack64 = 0;
}
opts->ext_copy.use_ack = 1;
Expand Down
8 changes: 4 additions & 4 deletions net/mptcp/protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ static void __mptcp_move_skb(struct mptcp_sock *msk, struct sock *ssk,

skb_ext_reset(skb);
skb_orphan(skb);
msk->ack_seq += copy_len;
WRITE_ONCE(msk->ack_seq, msk->ack_seq + copy_len);

tail = skb_peek_tail(&sk->sk_receive_queue);
if (offset == 0 && tail) {
Expand Down Expand Up @@ -261,7 +261,7 @@ static void mptcp_check_data_fin(struct sock *sk)
if (mptcp_pending_data_fin(sk, &rcv_data_fin_seq)) {
struct mptcp_subflow_context *subflow;

msk->ack_seq++;
WRITE_ONCE(msk->ack_seq, msk->ack_seq + 1);
WRITE_ONCE(msk->rcv_data_fin, 0);

sk->sk_shutdown |= RCV_SHUTDOWN;
Expand Down Expand Up @@ -1720,7 +1720,7 @@ struct sock *mptcp_sk_clone(const struct sock *sk,
msk->remote_key = mp_opt->sndr_key;
mptcp_crypto_key_sha(msk->remote_key, NULL, &ack_seq);
ack_seq++;
msk->ack_seq = ack_seq;
WRITE_ONCE(msk->ack_seq, ack_seq);
}

sock_reset_flag(nsk, SOCK_RCU_FREE);
Expand Down Expand Up @@ -2072,7 +2072,7 @@ bool mptcp_finish_join(struct sock *sk)
parent_sock = READ_ONCE(parent->sk_socket);
if (parent_sock && !sk->sk_socket)
mptcp_sock_graft(sk, parent_sock);
subflow->map_seq = msk->ack_seq;
subflow->map_seq = READ_ONCE(msk->ack_seq);
return true;
}

Expand Down

0 comments on commit 917944d

Please sign in to comment.