From 608bca3204428a7ace7300a6a909b9ff863c8c89 Mon Sep 17 00:00:00 2001 From: delphij Date: Tue, 21 Jul 2015 23:42:20 +0000 Subject: [PATCH] Fix resource exhaustion due to sessions stuck in LAST_ACK state. Security: CVE-2015-5358 Security: SA-15:13.tcp Submitted by: Jonathan Looney (Juniper SIRT) Reviewed by: lstewart git-svn-id: svn://svn.freebsd.org/base/stable/8@285779 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sys/netinet/tcp_output.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sys/netinet/tcp_output.c b/sys/netinet/tcp_output.c index d76e99d8a..27a8ff4f1 100644 --- a/sys/netinet/tcp_output.c +++ b/sys/netinet/tcp_output.c @@ -398,7 +398,7 @@ after_sack_rexmit: flags &= ~TH_FIN; } - if (len < 0) { + if (len <= 0) { /* * If FIN has been sent but not acked, * but we haven't been called to retransmit, @@ -408,9 +408,16 @@ after_sack_rexmit: * to (closed) window, and set the persist timer * if it isn't already going. If the window didn't * close completely, just wait for an ACK. + * + * We also do a general check here to ensure that + * we will set the persist timer when we have data + * to send, but a 0-byte window. This makes sure + * the persist timer is set even if the packet + * hits one of the "goto send" lines below. */ len = 0; - if (sendwin == 0) { + if ((sendwin == 0) && (TCPS_HAVEESTABLISHED(tp->t_state)) && + (off < (int) so->so_snd.sb_cc)) { tcp_timer_activate(tp, TT_REXMT, 0); tp->t_rxtshift = 0; tp->snd_nxt = tp->snd_una; -- 2.42.0