tcp: consider recv buf for the initial window scale
authorSoheil Hassas Yeganeh <soheil@google.com>
Fri, 29 Jul 2016 13:34:02 +0000 (09:34 -0400)
committerWilly Tarreau <w@1wt.eu>
Sun, 21 Aug 2016 21:22:39 +0000 (23:22 +0200)
commitaadf1c479d9a894293298086be0ef73db8cda2c3
tree1639cd9a507f29545e7b2b43fb1c59db6a3826f6
parent4f6b16928f80440995960c646de25da69a801ed0
tcp: consider recv buf for the initial window scale

commit f626300a3e776ccc9671b0dd94698fb3aa315966 upstream.

tcp_select_initial_window() intends to advertise a window
scaling for the maximum possible window size. To do so,
it considers the maximum of net.ipv4.tcp_rmem[2] and
net.core.rmem_max as the only possible upper-bounds.
However, users with CAP_NET_ADMIN can use SO_RCVBUFFORCE
to set the socket's receive buffer size to values
larger than net.ipv4.tcp_rmem[2] and net.core.rmem_max.
Thus, SO_RCVBUFFORCE is effectively ignored by
tcp_select_initial_window().

To fix this, consider the maximum of net.ipv4.tcp_rmem[2],
net.core.rmem_max and socket's initial buffer space.

Fixes: b0573dea1fb3 ("[NET]: Introduce SO_{SND,RCV}BUFFORCE socket options")
Signed-off-by: Soheil Hassas Yeganeh <soheil@google.com>
Suggested-by: Neal Cardwell <ncardwell@google.com>
Acked-by: Neal Cardwell <ncardwell@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Willy Tarreau <w@1wt.eu>
net/ipv4/tcp_output.c