mptcp: Safely store sequence number when sending data
authorMat Martineau <mathew.j.martineau@linux.intel.com>
Tue, 28 Jul 2020 22:12:10 +0000 (15:12 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 29 Jul 2020 00:02:42 +0000 (17:02 -0700)
The MPTCP socket's write_seq member can be read without the msk lock
held, so use WRITE_ONCE() to store it.

Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/mptcp/protocol.c

index f2455a6..687f0be 100644 (file)
@@ -793,7 +793,7 @@ static int mptcp_sendmsg_frag(struct sock *sk, struct sock *ssk,
 out:
        if (!retransmission)
                pfrag->offset += frag_truesize;
-       *write_seq += ret;
+       WRITE_ONCE(*write_seq, *write_seq + ret);
        mptcp_subflow_ctx(ssk)->rel_write_seq += ret;
 
        return ret;