Skip to content

Commit 7804764

Browse files
q2vendavem330
authored andcommitted
tcp: Fix data-races around sysctl_tcp_moderate_rcvbuf.
While reading sysctl_tcp_moderate_rcvbuf, it can be changed concurrently. Thus, we need to add READ_ONCE() to its readers. Fixes: 1da177e ("Linux-2.6.12-rc2") Signed-off-by: Kuniyuki Iwashima <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent ab1ba21 commit 7804764

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

net/ipv4/tcp_input.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ void tcp_rcv_space_adjust(struct sock *sk)
724724
* <prev RTT . ><current RTT .. ><next RTT .... >
725725
*/
726726

727-
if (sock_net(sk)->ipv4.sysctl_tcp_moderate_rcvbuf &&
727+
if (READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_moderate_rcvbuf) &&
728728
!(sk->sk_userlocks & SOCK_RCVBUF_LOCK)) {
729729
int rcvmem, rcvbuf;
730730
u64 rcvwin, grow;

net/mptcp/protocol.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1908,7 +1908,7 @@ static void mptcp_rcv_space_adjust(struct mptcp_sock *msk, int copied)
19081908
if (msk->rcvq_space.copied <= msk->rcvq_space.space)
19091909
goto new_measure;
19101910

1911-
if (sock_net(sk)->ipv4.sysctl_tcp_moderate_rcvbuf &&
1911+
if (READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_moderate_rcvbuf) &&
19121912
!(sk->sk_userlocks & SOCK_RCVBUF_LOCK)) {
19131913
int rcvmem, rcvbuf;
19141914
u64 rcvwin, grow;

0 commit comments

Comments
 (0)