aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/tcp_output.c
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2017-02-01 11:33:53 -0500
committerDavid S. Miller <davem@davemloft.net>2017-02-01 12:55:42 -0500
commit06425c308b92eaf60767bc71d359f4cbc7a561f8 (patch)
treea08cfa26bccb18c96d087ee257d8a99f0f804f53 /net/ipv4/tcp_output.c
parent63117f09c768be05a0bf465911297dc76394f686 (diff)
tcp: fix 0 divide in __tcp_select_window()
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>
Diffstat (limited to 'net/ipv4/tcp_output.c')
-rw-r--r--net/ipv4/tcp_output.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 1d5331a1b1dc..8ce50dc3ab8c 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -2518,9 +2518,11 @@ u32 __tcp_select_window(struct sock *sk)
2518 int full_space = min_t(int, tp->window_clamp, allowed_space); 2518 int full_space = min_t(int, tp->window_clamp, allowed_space);
2519 int window; 2519 int window;
2520 2520
2521 if (mss > full_space) 2521 if (unlikely(mss > full_space)) {
2522 mss = full_space; 2522 mss = full_space;
2523 2523 if (mss <= 0)
2524 return 0;
2525 }
2524 if (free_space < (full_space >> 1)) { 2526 if (free_space < (full_space >> 1)) {
2525 icsk->icsk_ack.quick = 0; 2527 icsk->icsk_ack.quick = 0;
2526 2528