Skip to content

Commit 0f1e4d0

Browse files
q2vendavem330
authored andcommitted
tcp: Fix data-races around sysctl_tcp_workaround_signed_windows.
While reading sysctl_tcp_workaround_signed_windows, it can be changed concurrently. Thus, we need to add READ_ONCE() to its readers. Fixes: 15d99e0 ("[TCP]: sysctl to allow TCP window > 32767 sans wscale") Signed-off-by: Kuniyuki Iwashima <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 7804764 commit 0f1e4d0

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

net/ipv4/tcp_output.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ void tcp_select_initial_window(const struct sock *sk, int __space, __u32 mss,
230230
* which we interpret as a sign the remote TCP is not
231231
* misinterpreting the window field as a signed quantity.
232232
*/
233-
if (sock_net(sk)->ipv4.sysctl_tcp_workaround_signed_windows)
233+
if (READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_workaround_signed_windows))
234234
(*rcv_wnd) = min(space, MAX_TCP_WINDOW);
235235
else
236236
(*rcv_wnd) = min_t(u32, space, U16_MAX);
@@ -285,7 +285,7 @@ static u16 tcp_select_window(struct sock *sk)
285285
* scaled window.
286286
*/
287287
if (!tp->rx_opt.rcv_wscale &&
288-
sock_net(sk)->ipv4.sysctl_tcp_workaround_signed_windows)
288+
READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_workaround_signed_windows))
289289
new_win = min(new_win, MAX_TCP_WINDOW);
290290
else
291291
new_win = min(new_win, (65535U << tp->rx_opt.rcv_wscale));

net/mptcp/options.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1271,7 +1271,7 @@ static void mptcp_set_rwin(struct tcp_sock *tp, struct tcphdr *th)
12711271
if (unlikely(th->syn))
12721272
new_win = min(new_win, 65535U) << tp->rx_opt.rcv_wscale;
12731273
if (!tp->rx_opt.rcv_wscale &&
1274-
sock_net(ssk)->ipv4.sysctl_tcp_workaround_signed_windows)
1274+
READ_ONCE(sock_net(ssk)->ipv4.sysctl_tcp_workaround_signed_windows))
12751275
new_win = min(new_win, MAX_TCP_WINDOW);
12761276
else
12771277
new_win = min(new_win, (65535U << tp->rx_opt.rcv_wscale));

0 commit comments

Comments
 (0)