svn commit: r363680 - head/sys/kern

John Baldwin jhb at FreeBSD.org
Wed Jul 29 23:24:33 UTC 2020


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)) {


More information about the svn-src-all mailing list