Date: Wed, 29 Jul 2020 23:24:33 +0000 (UTC) From: John Baldwin <jhb@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r363680 - head/sys/kern Message-ID: <202007292324.06TNOXhl088384@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jhb Date: Wed Jul 29 23:24:32 2020 New Revision: 363680 URL: https://svnweb.freebsd.org/changeset/base/363680 Log: Properly handle a closed TLS socket with pending receive data. If the remote end closes a TLS socket and the socket buffer still contains not-yet-decrypted TLS records but no decrypted TLS records, soreceive needs to block or fail with EWOULDBLOCK. Previously it was trying to return data and dereferencing a NULL pointer. Reviewed by: np Sponsored by: Chelsio Differential Revision: https://reviews.freebsd.org/D25838 Modified: head/sys/kern/uipc_socket.c Modified: head/sys/kern/uipc_socket.c ============================================================================== --- head/sys/kern/uipc_socket.c Wed Jul 29 23:21:56 2020 (r363679) +++ head/sys/kern/uipc_socket.c Wed Jul 29 23:24:32 2020 (r363680) @@ -1965,12 +1965,17 @@ restart: } SOCKBUF_LOCK_ASSERT(&so->so_rcv); if (so->so_rcv.sb_state & SBS_CANTRCVMORE) { - if (m == NULL && so->so_rcv.sb_tlsdcc == 0 && + if (m != NULL) + goto dontblock; +#ifdef KERN_TLS + else if (so->so_rcv.sb_tlsdcc == 0 && so->so_rcv.sb_tlscc == 0) { +#else + else { +#endif SOCKBUF_UNLOCK(&so->so_rcv); goto release; - } else - goto dontblock; + } } for (; m != NULL; m = m->m_next) if (m->m_type == MT_OOBDATA || (m->m_flags & M_EOR)) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202007292324.06TNOXhl088384>