Skip to content

Commit 06425c3

Browse files
edumazetdavem330
authored andcommitted
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>
1 parent 63117f0 commit 06425c3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

net/ipv4/tcp_output.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2518,9 +2518,11 @@ u32 __tcp_select_window(struct sock *sk)
25182518
int full_space = min_t(int, tp->window_clamp, allowed_space);
25192519
int window;
25202520

2521-
if (mss > full_space)
2521+
if (unlikely(mss > full_space)) {
25222522
mss = full_space;
2523-
2523+
if (mss <= 0)
2524+
return 0;
2525+
}
25242526
if (free_space < (full_space >> 1)) {
25252527
icsk->icsk_ack.quick = 0;
25262528

0 commit comments

Comments
 (0)