Commit ad32b3c3 authored by David S. Miller's avatar David S. Miller

Merge branch 'tcp-wmem-data-races'

Jason Xing says:

====================
annotate data-races around sysctl_tcp_wmem[0]

Adding simple READ_ONCE() can avoid reading the sysctl knob meanwhile
someone is trying to change it.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 900b2801 683a67da
...@@ -975,7 +975,7 @@ int tcp_wmem_schedule(struct sock *sk, int copy) ...@@ -975,7 +975,7 @@ int tcp_wmem_schedule(struct sock *sk, int copy)
* Use whatever is left in sk->sk_forward_alloc and tcp_wmem[0] * Use whatever is left in sk->sk_forward_alloc and tcp_wmem[0]
* to guarantee some progress. * to guarantee some progress.
*/ */
left = sock_net(sk)->ipv4.sysctl_tcp_wmem[0] - sk->sk_wmem_queued; left = READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_wmem[0]) - sk->sk_wmem_queued;
if (left > 0) if (left > 0)
sk_forced_mem_schedule(sk, min(left, copy)); sk_forced_mem_schedule(sk, min(left, copy));
return min(copy, sk->sk_forward_alloc); return min(copy, sk->sk_forward_alloc);
......
...@@ -850,7 +850,7 @@ static inline void __mptcp_sync_sndbuf(struct sock *sk) ...@@ -850,7 +850,7 @@ static inline void __mptcp_sync_sndbuf(struct sock *sk)
if (sk->sk_userlocks & SOCK_SNDBUF_LOCK) if (sk->sk_userlocks & SOCK_SNDBUF_LOCK)
return; return;
new_sndbuf = sock_net(sk)->ipv4.sysctl_tcp_wmem[0]; new_sndbuf = READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_wmem[0]);
mptcp_for_each_subflow(mptcp_sk(sk), subflow) { mptcp_for_each_subflow(mptcp_sk(sk), subflow) {
ssk_sndbuf = READ_ONCE(mptcp_subflow_tcp_sock(subflow)->sk_sndbuf); ssk_sndbuf = READ_ONCE(mptcp_subflow_tcp_sock(subflow)->sk_sndbuf);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment