HomeFreeBSD

unix/dgram: smart socket buffers for one-to-many sockets

Description

unix/dgram: smart socket buffers for one-to-many sockets

A one-to-many unix/dgram socket is a socket that has been bound
with bind(2) and can get multiple connections. A typical example
is /var/run/log bound by syslogd(8) and receiving multiple
connections from libc syslog(3) API. Until now all of these
connections shared the same receive socket buffer of the bound
socket. This made the socket vulnerable to overflow attack.
See 240d5a9b1ce for a historical attempt to workaround the problem.

This commit creates a per-connection socket buffer for every single
connected socket and eliminates the problem. The new behavior will
optimize seldom writers over frequent writers. See added test case
scenarios and code comments for more detailed description of the
new behavior.

Reviewed by: markj
Differential revision: https://reviews.freebsd.org/D35303

Details

Provenance
glebiusAuthored on Jun 24 2022, 4:09 PM
Reviewer
markj
Differential Revision
D35303: unix/dgram: smart socket buffers for one-to-many sockets
Parents
rG1093f16487a9: unix/dgram: reduce mbuf chain traversals in send(2) and recv(2)
Branches
Unknown
Tags
Unknown