]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
tcp: sysctl: Fix a race to avoid unexpected 0 window from space
authorGao Feng <fgao@ikuai8.com>
Thu, 23 Mar 2017 23:05:12 +0000 (07:05 +0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 24 Mar 2017 20:29:16 +0000 (13:29 -0700)
commitc48367427a39ea0b85c7cf018fe4256627abfd9e
tree740f51767793ae5765a0ecedc931c1704d0bbf06
parente013fb7c4c9fa8aa914d85d8b466c990b2eaebb6
tcp: sysctl: Fix a race to avoid unexpected 0 window from space

Because sysctl_tcp_adv_win_scale could be changed any time, so there
is one race in tcp_win_from_space.
For example,
1.sysctl_tcp_adv_win_scale<=0 (sysctl_tcp_adv_win_scale is negative now)
2.space>>(-sysctl_tcp_adv_win_scale) (sysctl_tcp_adv_win_scale is postive now)

As a result, tcp_win_from_space returns 0. It is unexpected.

Certainly if the compiler put the sysctl_tcp_adv_win_scale into one
register firstly, then use the register directly, it would be ok.
But we could not depend on the compiler behavior.

Signed-off-by: Gao Feng <fgao@ikuai8.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/tcp.h