]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
unix/dgram: smart socket buffers for one-to-many sockets
authorGleb Smirnoff <glebius@FreeBSD.org>
Fri, 24 Jun 2022 16:09:11 +0000 (09:09 -0700)
committerGleb Smirnoff <glebius@FreeBSD.org>
Fri, 24 Jun 2022 16:09:11 +0000 (09:09 -0700)
commit458f475df8e5912609c14208c189414a8255c738
tree2fd7b17d07f2011d772d37450605615d113937d2
parent1093f16487a93c3ecdea910ca7249375873969da
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
share/man/man4/unix.4
sys/kern/uipc_usrreq.c
sys/sys/sockbuf.h
tests/sys/kern/unix_dgram.c