From nobody Mon Aug 12 23:05:32 2024 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 4WjVVN4MqRz5TMt4; Mon, 12 Aug 2024 23:05:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (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-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WjVVN1QVSz4fdL; Mon, 12 Aug 2024 23:05:32 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1723503932; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=HgPaWe6IfEFljcj4tX+/hmK7o5CKRXWvE4SK1ct9AZk=; b=g7wzWFliMAmi5UaXe52o5VgaynnWFw0AHfTrnf1m9wQUfSB+EuH+Ash7JCbOk+N0S6o7+/ oWQG870P8a2mI6PBSGCmHsWV7quCNATb9+ArMJ4nLx+RY0H1L4YoJqGfXF21pT6q9G7yaY yEaPWd0nWy1alrJwpmAVX2SXg5xEDrgSIjJp2LwTXbkgolNTXW3+EeM7feep8nWEw10GDV iPw1ELcfu+2m42UFReTfuCQ+hxtCpKoukL5HBTj/GqtsNBkOyfuC68bHSK2I/5li4WPG76 pv9PQ5setfCpdTR7AW+9kbJGyyY0CHnJUSxrelehmPQ7mqg2mAPJ3vbL9+CGOQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1723503932; a=rsa-sha256; cv=none; b=iaSHUG/PxvUbRIoVOk2ojdDnZUN1S1c2DDWCsk7FSiLMdWdFclzY0n0KJLUOjpUaOkqYpj nmENtcpMG8oLKOVVkaatSuiNYlUIeKim0A5s+4B9TgYPzKQaAsBSJnzOkcIsLCigkI4ed2 JFrzuviL8iYhz/0Hvu0cPsWt3ljdSlXex6STTn7npEIEPp6BlNvJvSBTyOhcvW0VKd2XJz M0IdmAEJ/N1dBGsYXoihb0B3qLtJsWlDrRSXrjjJFn7qaLSOVzSkOQlEs0utqUiGIiQf/5 WMJ5U9yCawXyi0ucyWomiFgaq51Ngr2tTQSOK2g0/Zo9w7blMklOuto9SkvBYQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1723503932; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=HgPaWe6IfEFljcj4tX+/hmK7o5CKRXWvE4SK1ct9AZk=; b=X3RoMPuxw2og9FGcCulC+LhGOb3AwGp1MekSgGDlYO40EFfbSmazb+fqV6oDFXrHDOKxjV +s7pS61ffg2mrTA+rc5Yao1FEqIClj4OOooX4Pgr33CNKHymdgS2zrgGQTnyNgPAjPckpg fjC82NDoJw3bpc0lLP5dYHO5eTGJWgJ48B2Ve4J79P9xLK9fikOY+cTR+FUiyaLTlg12pk dJliTb3mOg5MlpmF8Mf0rUeygwWET6pmN3joupmnz1cpBiqppNubbCeGyIJCmn8ApsZHev KXjxrAHXRi1Gx6YQtypx/NejChfsCkQ+JeH3Uhp1BI8PFeXQf23UHH3Yvi+Ecw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4WjVVN0rmDzml3; Mon, 12 Aug 2024 23:05:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 47CN5Wk3072139; Mon, 12 Aug 2024 23:05:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 47CN5WeG072136; Mon, 12 Aug 2024 23:05:32 GMT (envelope-from git) Date: Mon, 12 Aug 2024 23:05:32 GMT Message-Id: <202408122305.47CN5WeG072136@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: fc4365853f1c - main - socket: Fix handling of listening sockets in sotoxsocket() List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fc4365853f1c4b572d9fd643ea336508d9a6a0f7 Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=fc4365853f1c4b572d9fd643ea336508d9a6a0f7 commit fc4365853f1c4b572d9fd643ea336508d9a6a0f7 Author: Mark Johnston AuthorDate: 2024-07-09 20:28:12 +0000 Commit: Mark Johnston CommitDate: 2024-08-12 22:53:26 +0000 socket: Fix handling of listening sockets in sotoxsocket() A lock needs to be held to ensure that the socket does not become a listening socket while sotoxsocket() is loading fields from the socket buffers, as the memory backing the socket buffers is repurposed when transitioning to a listening socket. MFC after: 1 week Sponsored by: Klara, Inc. Sponsored by: Stormshield --- sys/kern/uipc_socket.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 0350a5eb4d87..9a44c1d557f0 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -4277,6 +4277,7 @@ sotoxsocket(struct socket *so, struct xsocket *xso) xso->so_error = so->so_error; xso->so_uid = so->so_cred->cr_uid; xso->so_pgid = so->so_sigio ? so->so_sigio->sio_pgid : 0; + SOCK_LOCK(so); if (SOLISTENING(so)) { xso->so_qlen = so->sol_qlen; xso->so_incqlen = so->sol_incqlen; @@ -4289,6 +4290,7 @@ sotoxsocket(struct socket *so, struct xsocket *xso) sbtoxsockbuf(&so->so_snd, &xso->so_snd); sbtoxsockbuf(&so->so_rcv, &xso->so_rcv); } + SOCK_UNLOCK(so); } int