HomeFreeBSD

unix/stream: do not put empty mbufs on the socket

Description

unix/stream: do not put empty mbufs on the socket

It is a legitimate case to use sendmsg(2) to send control only, with zero
bytes of data and then recvmsg(2) them with zero length iov, receiving
control only. This sendmsg(2)+recmsg(2) would leave a zero length mbuf on
the top of the socket buffer. If you now try to repeat this combo again,
your recvmsg(2) would not return control data, because it sits behind an
MT_DATA mbuf and you have provided zero length uio_resid. IMHO, best
strategy to deal with zero length buffers in a chain is to not put them
there in the first place. Thus, solve this right in uipc_send() instead
of touching soreceive_generic().

Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D43733

Details

Provenance
glebiusAuthored on Feb 8 2024, 5:00 PM
Reviewer
markj
Differential Revision
D43733: unix/stream: do not put empty mbufs on the socket
Parents
rG3f0b10892442: traceroute: remove rcsid tags
Branches
Unknown
Tags
Unknown