aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/uipc_socket.c
diff options
context:
space:
mode:
authorRick Macklem <rmacklem@FreeBSD.org>2020-04-27 23:55:09 +0000
committerRick Macklem <rmacklem@FreeBSD.org>2020-04-27 23:55:09 +0000
commit03066893675593c74db137389dadb40ea0f39737 (patch)
tree79c5d53dca8a56cee91ac03fdd65eb673e8cba1c /sys/kern/uipc_socket.c
parent75ce42271a3ca991d27c92a2732b36fa31a058f0 (diff)
downloadsrc-03066893675593c74db137389dadb40ea0f39737.tar.gz
src-03066893675593c74db137389dadb40ea0f39737.zip
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
Notes
Notes: svn path=/head/; revision=360416
Diffstat (limited to 'sys/kern/uipc_socket.c')
-rw-r--r--sys/kern/uipc_socket.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index dd86c9050924..d098102634cc 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -1557,8 +1557,10 @@ sosend_generic(struct socket *so, struct sockaddr *addr, struct uio *uio,
#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