Re: git: 6144315d1612 - main - unix: Fix a race between shutdown and listen

From: Gleb Smirnoff <glebius_at_freebsd.org>
Date: Tue, 17 Nov 2026 20:20:22 UTC
On Tue, Nov 17, 2026 at 05:01:49PM +0000, Mark Johnston wrote:
M> The branch main has been updated by markj:
M> 
M> URL: https://cgit.FreeBSD.org/src/commit/?id=6144315d1612bc0c3a7ffd22e75aa1fe06dee1ca
M> 
M> commit 6144315d1612bc0c3a7ffd22e75aa1fe06dee1ca
M> Author:     Mark Johnston <markj@FreeBSD.org>
M> AuthorDate: 2026-11-09 22:27:45 +0000
M> Commit:     Mark Johnston <markj@FreeBSD.org>
M> CommitDate: 2026-11-17 16:57:01 +0000
M> 
M>     unix: Fix a race between shutdown and listen
M>     
M>     In uipc_shutdown(), the SOLISTENING() check is stale as soon as the
M>     socket lock is dropped.  Acquire the unpcb lock earlier and use that to
M>     interlock with other work that touches the socket buffers which are
M>     invalid for a listening socket.  Fix unp_dispose() to handle errors when
M>     acquiring the I/O lock; contrary to the assertions, such races are
M>     possible.
M>     
M>     Approved by:    so
M>     Security:       FreeBSD-SA-26:83.unix
M>     Security:       CVE-2026-127751
M>     Reported by:    OpenAI Security Research Team
M>     Sponsored by:   The FreeBSD Foundation

I wonder if this could be avoided if we had pr_lock method and more streamlined
operation of listen(2).  Maybe revisit https://reviews.freebsd.org/D48709 ?

-- 
Gleb Smirnoff