From owner-svn-src-head@freebsd.org Fri May 18 19:09:12 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 21837EB1E7C; Fri, 18 May 2018 19:09:12 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C6531848C3; Fri, 18 May 2018 19:09:11 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9DBA11C2AB; Fri, 18 May 2018 19:09:11 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w4IJ9Blv044994; Fri, 18 May 2018 19:09:11 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w4IJ9BYp044993; Fri, 18 May 2018 19:09:11 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201805181909.w4IJ9BYp044993@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Fri, 18 May 2018 19:09:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r333810 - head/sys/dev/cxgbe/tom X-SVN-Group: head X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: head/sys/dev/cxgbe/tom X-SVN-Commit-Revision: 333810 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 May 2018 19:09:12 -0000 Author: jhb Date: Fri May 18 19:09:11 2018 New Revision: 333810 URL: https://svnweb.freebsd.org/changeset/base/333810 Log: Be more robust against garbage input on a TOE TLS TX socket. If a socket is closed or shutdown and a partial record (or what appears to be a partial record) is waiting in the socket buffer, discard the partial record and close the connection rather than waiting forever for the rest of the record. Reported by: Harsh Jain @ Chelsio Sponsored by: Chelsio Communications Modified: head/sys/dev/cxgbe/tom/t4_tls.c Modified: head/sys/dev/cxgbe/tom/t4_tls.c ============================================================================== --- head/sys/dev/cxgbe/tom/t4_tls.c Fri May 18 18:48:00 2018 (r333809) +++ head/sys/dev/cxgbe/tom/t4_tls.c Fri May 18 19:09:11 2018 (r333810) @@ -1189,17 +1189,23 @@ t4_push_tls_records(struct adapter *sc, struct toepcb /* * A full TLS header is not yet queued, stop * for now until more data is added to the - * socket buffer. + * socket buffer. However, if the connection + * has been closed, we will never get the rest + * of the header so just discard the partial + * header and close the connection. */ #ifdef VERBOSE_TRACES - CTR4(KTR_CXGBE, "%s: tid %d sbavail %d sb_off %d", - __func__, toep->tid, sbavail(sb), tls_ofld->sb_off); + CTR5(KTR_CXGBE, "%s: tid %d sbavail %d sb_off %d%s", + __func__, toep->tid, sbavail(sb), tls_ofld->sb_off, + toep->flags & TPF_SEND_FIN ? "" : " SEND_FIN"); #endif if (sowwakeup) sowwakeup_locked(so); else SOCKBUF_UNLOCK(sb); SOCKBUF_UNLOCK_ASSERT(sb); + if (toep->flags & TPF_SEND_FIN) + t4_close_conn(sc, toep); return; } @@ -1216,19 +1222,25 @@ t4_push_tls_records(struct adapter *sc, struct toepcb /* * The full TLS record is not yet queued, stop * for now until more data is added to the - * socket buffer. + * socket buffer. However, if the connection + * has been closed, we will never get the rest + * of the record so just discard the partial + * record and close the connection. */ #ifdef VERBOSE_TRACES - CTR5(KTR_CXGBE, - "%s: tid %d sbavail %d sb_off %d plen %d", + CTR6(KTR_CXGBE, + "%s: tid %d sbavail %d sb_off %d plen %d%s", __func__, toep->tid, sbavail(sb), tls_ofld->sb_off, - plen); + plen, toep->flags & TPF_SEND_FIN ? "" : + " SEND_FIN"); #endif if (sowwakeup) sowwakeup_locked(so); else SOCKBUF_UNLOCK(sb); SOCKBUF_UNLOCK_ASSERT(sb); + if (toep->flags & TPF_SEND_FIN) + t4_close_conn(sc, toep); return; }