From nobody Tue Nov 17 21:28:36 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4jTdBt69RTz71v8s; Tue, 17 Nov 2026 21:28:38 +0000 (UTC) (envelope-from markj@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jTdBt5g8Hz4Jmg; Tue, 17 Nov 2026 21:28:38 +0000 (UTC) (envelope-from markj@freebsd.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794950918; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Q6qk3fLXg+KYGsdJEtGWIezcZGvIqGxBiiU4N1OxKXs=; b=hR0W0MXYtXBwKXOQfon8YYnfYWlaQpESBmWFEUCH0TjYNXTLek+5g3eZ9C6959jCb9AUaX 4dzcju+t9nTe5RIwRQgvnXxeb0UZ5CEJtJgsGLV4f1tP8NCpXE4bK0ksRTDmFnndmG+ISB Y7F22TQ0deOospeU4tSGxgb8gs7EbvI5GpKsPJQViU1DB7FaAMSQC4zBJHl1vWzXSr761q JW5k7f8W8GSqPXcKYjUotCj98yOYR6uElY2plikRN96mfXyYVRh90zt/40/dDReb7hJEEh R8FTyonh3nKhi0cXhZ/aQK/ja2ZWN8dbfIHK1vU9P8BNCv1CqY0KqykzxuFK+Q== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794950918; b=abaV1X4GHNu6J5oWPO8N3MugqOeHW6zXeONh5NiLmNoKdBM9c1HDBvN5NHNPlu6ty8k9H8 JD3fg7y3mGs88Sv+luVzXqIhG5eMv+84u0u6fVEKo8rWbjgRpXEPwMo+NE9SAYJGpg0H0F nqCRpBsWtHqwkkkkFwQxqcHA4110+zqWVTII8mYXxrSYSq1tWmEKlAAA6Ub8zPnD8hbn3p rMXuv0C2HyM+FGnToz8itvkHbo5ojX3bj+MmRrf/TSxWps2vLhoCOybyUJkWJ5g6+3cWXE pP6fanaXefg9pHIvHiTs9E3VD31NWvVMbgsbg0/fT9IW71NbEDkyQq1wNB2gFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794950918; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Q6qk3fLXg+KYGsdJEtGWIezcZGvIqGxBiiU4N1OxKXs=; b=msPbvfn9XtShdJYOE2xnCO5RqwB382ZCIXJ1z3vsYewp6J+wSO8OtDLlXVIx3cZOIVTbZK yscOQFs2RccRQda7pTBQ5b36TdrHVe56Te2fDd2DLylC6kdavzlvNxC4emXurGbikzu1y5 QMbtWe2fg3O1cuCoxn6FC+W3SsEWiLxLl4KpxuxAQZ+0GL3ye28RIpS6rGowo4wmp0ZVuA xfgd4Oxp2TJtbOoyUCYAJ/KGHK75WxwUgPg3X4swo//Vy/+Ps4FOHXo1GDfiYD9BkoKROU 18KMuXnpg6eZFW+gwGDRRfzp6XJRm8zViKk2GtfsHknquuH42JScXgQ82i2vjA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from nuc (198-84-224-249.cpe.teksavvy.com [198.84.224.249]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: markj) by smtp.freebsd.org (Postfix) with ESMTPSA id 4jTdBt2mbNzYBT; Tue, 17 Nov 2026 21:28:38 +0000 (UTC) (envelope-from markj@freebsd.org) Date: Tue, 17 Nov 2026 16:28:36 -0500 From: Mark Johnston To: Gleb Smirnoff Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: 6144315d1612 - main - unix: Fix a race between shutdown and listen Message-ID: References: <6afc887d.1ced7.733cf5d4@gitrepo.freebsd.org> List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Tue, Nov 17, 2026 at 12:20:22PM -0800, Gleb Smirnoff wrote: > 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 > M> AuthorDate: 2026-11-09 22:27:45 +0000 > M> Commit: Mark Johnston > 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 ? Really a lot of these problems come from the fact that we started overlaying listening socket fields over top of regular socket buffer fields, as an optimization to shrink struct socket. struct socket effectively represents two different types. Then, since listen(2) can be called at any time, any code which handles sockets has to be very careful to make sure the socket type can't flip. We've had more than one bug due to this. pr_lock might make the synchronization rules a bit simpler, but the underlying problem is the potential for type confusion between data sockets and listening sockets. Even with simpler locking rules, it's too easy to miss an SOLISTENING() check somewhere. So probably the distinction between listening sockets and data sockets needs to be reflected in the type system, e.g., have a separate DTYPE_LSOCKET file type and struct lsocket type, and make listen() convert an existing data socket to that type. Fail if the underlying file structure is concurrently referenced by a different thread, or if it can't be converted atomically with respect to fget() lookups. I'm not sure how challenging that would be to implement.