Skip to content

Commit 36eeee7

Browse files
q2vendavem330
authored andcommitted
tcp: Fix a data-race around sysctl_tcp_adv_win_scale.
While reading sysctl_tcp_adv_win_scale, it can be changed concurrently. Thus, we need to add READ_ONCE() to its reader. Fixes: 1da177e ("Linux-2.6.12-rc2") Signed-off-by: Kuniyuki Iwashima <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 02ca527 commit 36eeee7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

include/net/tcp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1419,7 +1419,7 @@ void tcp_select_initial_window(const struct sock *sk, int __space,
14191419

14201420
static inline int tcp_win_from_space(const struct sock *sk, int space)
14211421
{
1422-
int tcp_adv_win_scale = sock_net(sk)->ipv4.sysctl_tcp_adv_win_scale;
1422+
int tcp_adv_win_scale = READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_adv_win_scale);
14231423

14241424
return tcp_adv_win_scale <= 0 ?
14251425
(space>>(-tcp_adv_win_scale)) :

0 commit comments

Comments
 (0)