From: Kuniyuki Iwashima Date: Fri, 22 Jul 2022 18:22:01 +0000 (-0700) Subject: tcp: Fix a data-race around sysctl_tcp_comp_sack_delay_ns. X-Git-Tag: v5.15.73~1856 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6842c94de9d5b25e0fbfa3402f4c3d6a382f7fae;p=platform%2Fkernel%2Flinux-rpi.git tcp: Fix a data-race around sysctl_tcp_comp_sack_delay_ns. [ Upstream commit 4866b2b0f7672b6d760c4b8ece6fb56f965dcc8a ] While reading sysctl_tcp_comp_sack_delay_ns, it can be changed concurrently. Thus, we need to add READ_ONCE() to its reader. Fixes: 6d82aa242092 ("tcp: add tcp_comp_sack_delay_ns sysctl") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index e007bdc..486ca1d 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -5512,7 +5512,8 @@ send_now: if (tp->srtt_us && tp->srtt_us < rtt) rtt = tp->srtt_us; - delay = min_t(unsigned long, sock_net(sk)->ipv4.sysctl_tcp_comp_sack_delay_ns, + delay = min_t(unsigned long, + READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_comp_sack_delay_ns), rtt * (NSEC_PER_USEC >> 3)/20); sock_hold(sk); hrtimer_start_range_ns(&tp->compressed_ack_timer, ns_to_ktime(delay),