Skip to content

Commit e7d2ef8

Browse files
q2vendavem330
authored andcommitted
tcp: Fix data-races around sysctl_tcp_recovery.
While reading sysctl_tcp_recovery, it can be changed concurrently. Thus, we need to add READ_ONCE() to its readers. Fixes: 4f41b1c ("tcp: use RACK to detect losses") Signed-off-by: Kuniyuki Iwashima <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 52e6586 commit e7d2ef8

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

net/ipv4/tcp_input.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2095,7 +2095,8 @@ static inline void tcp_init_undo(struct tcp_sock *tp)
20952095

20962096
static bool tcp_is_rack(const struct sock *sk)
20972097
{
2098-
return sock_net(sk)->ipv4.sysctl_tcp_recovery & TCP_RACK_LOSS_DETECTION;
2098+
return READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_recovery) &
2099+
TCP_RACK_LOSS_DETECTION;
20992100
}
21002101

21012102
/* If we detect SACK reneging, forget all SACK information

net/ipv4/tcp_recovery.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ static u32 tcp_rack_reo_wnd(const struct sock *sk)
1414
return 0;
1515

1616
if (tp->sacked_out >= tp->reordering &&
17-
!(sock_net(sk)->ipv4.sysctl_tcp_recovery & TCP_RACK_NO_DUPTHRESH))
17+
!(READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_recovery) &
18+
TCP_RACK_NO_DUPTHRESH))
1819
return 0;
1920
}
2021

@@ -187,7 +188,8 @@ void tcp_rack_update_reo_wnd(struct sock *sk, struct rate_sample *rs)
187188
{
188189
struct tcp_sock *tp = tcp_sk(sk);
189190

190-
if (sock_net(sk)->ipv4.sysctl_tcp_recovery & TCP_RACK_STATIC_REO_WND ||
191+
if ((READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_recovery) &
192+
TCP_RACK_STATIC_REO_WND) ||
191193
!rs->prior_delivered)
192194
return;
193195

0 commit comments

Comments
 (0)