Skip to content

Commit

Permalink
tcp: fix 0 divide in __tcp_select_window()
Browse files Browse the repository at this point in the history
[ Upstream commit 06425c3 ]

syszkaller fuzzer was able to trigger a divide by zero, when
TCP window scaling is not enabled.

SO_RCVBUF can be used not only to increase sk_rcvbuf, also
to decrease it below current receive buffers utilization.

If mss is negative or 0, just return a zero TCP window.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Dmitry Vyukov  <dvyukov@google.com>
Acked-by: Neal Cardwell <ncardwell@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
  • Loading branch information
Eric Dumazet authored and Jiri Slaby committed Mar 1, 2017
1 parent 47ba15d commit c48ae3c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions net/ipv4/tcp_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -2163,9 +2163,11 @@ u32 __tcp_select_window(struct sock *sk)
int full_space = min_t(int, tp->window_clamp, tcp_full_space(sk));
int window;

if (mss > full_space)
if (unlikely(mss > full_space)) {
mss = full_space;

if (mss <= 0)
return 0;
}
if (free_space < (full_space >> 1)) {
icsk->icsk_ack.quick = 0;

Expand Down

0 comments on commit c48ae3c

Please sign in to comment.