Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 27 Apr 2020 23:55:10 +0000 (UTC)
From:      Rick Macklem <rmacklem@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r360416 - head/sys/kern
Message-ID:  <202004272355.03RNtADW082947@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rmacklem
Date: Mon Apr 27 23:55:09 2020
New Revision: 360416
URL: https://svnweb.freebsd.org/changeset/base/360416

Log:
  Fix sosend_generic() so that it can handle a list of ext_pgs mbufs.
  
  Without this patch, sosend_generic() will try to use top->m_pkthdr.len,
  assuming that the first mbuf has a pkthdr.
  When a list of ext_pgs mbufs is passed in, the first mbuf is not a
  pkthdr and cannot be post-r359919.  As such, the value of top->m_pkthdr.len
  is bogus (0 for my testing).
  This patch fixes sosend_generic() to handle this case, calculating the
  total length via m_length() for this case.
  
  There is currently nothing that hands a list of ext_pgs mbufs to
  sosend_generic(), but the nfs-over-tls kernel RPC code in
  projects/nfs-over-tls will do that and was used to test this patch.
  
  Reviewed by:	gallatin
  Differential Revision:	https://reviews.freebsd.org/D24568

Modified:
  head/sys/kern/uipc_socket.c

Modified: head/sys/kern/uipc_socket.c
==============================================================================
--- head/sys/kern/uipc_socket.c	Mon Apr 27 23:49:13 2020	(r360415)
+++ head/sys/kern/uipc_socket.c	Mon Apr 27 23:55:09 2020	(r360416)
@@ -1557,8 +1557,10 @@ sosend_generic(struct socket *so, struct sockaddr *add
 #endif
 	if (uio != NULL)
 		resid = uio->uio_resid;
-	else
+	else if ((top->m_flags & M_PKTHDR) != 0)
 		resid = top->m_pkthdr.len;
+	else
+		resid = m_length(top, NULL);
 	/*
 	 * In theory resid should be unsigned.  However, space must be
 	 * signed, as it might be less than 0 if we over-committed, and we



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202004272355.03RNtADW082947>