History

tcp: Fix data-races around sk_pacing_rate.

While reading sysctl_tcp_pacing_(ss|ca)_ratio, they can be changed concurrently. Thus, we need to add READ_ONCE() to their readers.

Kuniyuki Iwashima committed 4 years ago

Commit 59bf6c61 parent 3e7d18b1 file · +2 −2Browse files

Unified · Split

net/ipv4/tcp_input.c+2−2
@@ -910,9 +910,9 @@ static void tcp_update_pacing_rate(struct sock *sk) · 909 unmodified lines
910 * end of slow start and should slow down.910 * end of slow start and should slow down.
911 */911 */
912 if (tcp_snd_cwnd(tp) < tp->snd_ssthresh / 2)912 if (tcp_snd_cwnd(tp) < tp->snd_ssthresh / 2)
913 rate *= sock_net(sk)->ipv4.sysctl_tcp_pacing_ss_ratio;913 rate *= READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_pacing_ss_ratio);
914 else914 else
915 rate *= sock_net(sk)->ipv4.sysctl_tcp_pacing_ca_ratio;915 rate *= READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_pacing_ca_ratio);
916 916
917 rate *= max(tcp_snd_cwnd(tp), tp->packets_out);917 rate *= max(tcp_snd_cwnd(tp), tp->packets_out);
918 918