Rework garbage collector for unix(4) sockets.
authormvs <mvs@openbsd.org>
Sun, 26 Dec 2021 23:41:41 +0000 (23:41 +0000)
committermvs <mvs@openbsd.org>
Sun, 26 Dec 2021 23:41:41 +0000 (23:41 +0000)
commite82b5ebce50ce92a513ef50cef3ae51dcab7c4a0
treef4fb532f6b0829769b8434d6612ae2956fe66315
parent947bb3e060b4fd52f0a3bacd78420c8dff737afe
Rework garbage collector for unix(4) sockets.

This time unix(4) sockets garbage collector always destroys any socket
with positive "fp->f_count == unp->unp_msgcount" equation. This is wrong
because unix(4) sockets within SCM_RIGHTS message but closed on sender
side also have this equation positive. Such sockets are not in the loop,
and if garbage collector kill them before they are received, we get
kernel panic.

FreeBSD already has garbage collector reworked to fix this issue [1]. The
logic is pretty simple so import it to our garbage collector.

1. https://reviews.freebsd.org/D23142

ok bluhm@
sys/kern/uipc_usrreq.c
sys/sys/unpcb.h