From nobody Tue Nov 17 17:02:52 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 4jTWJF35GZz71QVd for ; Tue, 17 Nov 2026 17:02:53 +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) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jTWJD681Pz4C8c for ; Tue, 17 Nov 2026 17:02:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794934972; 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: content-transfer-encoding:content-transfer-encoding; bh=WxhB18k+o0dkr3F3xVRc5mS/v+wVYrIfRV2l772UWoI=; b=ZIE0lY+AFCJ70Eofswsb1v+gD+UUtWWQAax6NHslzqZI0mouf5Dq8RkgVybg9si+0+tAm7 zQDptNWNQ9iHU5ONtGpSBGu4yH841625hHl0G8DotGvqAZ7WLIGatNHYIvWTZ5GTmJuV3O FpAgi0PLOxKxmWOE+Bg4VVfTMnT8xaEGvjyaXkL2mB+rdUFQILBI1fRXMkDhK5lEl/mZtY uV8LQoSAUqVb0MAFJVoOaF3kiZ0VduHGxgLy7GlwTWrHFx7kL9qdunwU1DEY1OmlhkBQ1K BWVTBH/oJ2kKKigFaGfnj5T8Y8b3IxASnL+NP4tfHRj8YQZUkaitoTW/LgXduA== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794934972; b=BYWQY2zz46efHI7Bfd3n0CE1BwgtzAslJ/ROgKdB/1mL3gcNC1qXIOxvGhdR15tQ3Gysxh vYXXw4H5vGPwzmn/lR5AeX58NpT9mwvTefIo1/v6S/Sesaubqe/uAuiSPVkPDHyrqamTxa CR/9gtg+uxsfU9vcgdDMQ2i88uJe4qHdJkWNZEKTy1XC6tcPyFXCwdPEbyudgS3bMmI1FU 3Zunu4wvFZd5euWidW6nNGqfk0xDjfW4/RToHUPPwNi6zytYy0LuAj5oMn3FhfWE3M8SD6 HCGyKUTUMa6lh1xCFu0x8imLarnGDMhAZTjUlC15+ahJZ8Cj6j/15JgNktUrHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794934972; 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: content-transfer-encoding:content-transfer-encoding; bh=WxhB18k+o0dkr3F3xVRc5mS/v+wVYrIfRV2l772UWoI=; b=qIV788zeYUW2SR8V4hgFDZLrijNUOa5fXil+9a/74mxdk47CWpVHkbVyjuimojGcPWhcV1 P1OJl4x7/v3/zgRSG1xz7DCcsWNgeINRGJvaBku87tive9G+wwO5vNkmF+9prE8ElvL2Qf t0GT67D8SSuCTEiDLVRBd/XnKFTMrHdRl+fCtTJdaPqUDbWfpk17p7VoAdQwODvnRgjidt XDkQKMvvXXJSP/18Gf1V/ZWGNgF4bYjuQLVrP2727M6tr/3bLwURQqPb3kCijS7oT/R4BG 0Bpu4PiwUQ2G4k5RHAIh9/qD/0HPGDD5zilnO6XMyZkXr2Mwd+mcGxCj5uYuEw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jTWJD5cMhzrM7 for ; Tue, 17 Nov 2026 17:02:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1d1bd by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 17 Nov 2026 17:02:52 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Cc: Andrew Gallatin From: Mark Johnston Subject: git: 770229de5de0 - stable/14 - splice: Fix leaks that can happen when initiating a splice 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=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 770229de5de03ea9776578bbbc6883b07bfe12c0 Auto-Submitted: auto-generated Date: Tue, 17 Nov 2026 17:02:52 +0000 Message-Id: <6afc88bc.1d1bd.1fe2a323@gitrepo.freebsd.org> The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=770229de5de03ea9776578bbbc6883b07bfe12c0 commit 770229de5de03ea9776578bbbc6883b07bfe12c0 Author: Andrew Gallatin AuthorDate: 2025-12-09 21:06:20 +0000 Commit: Mark Johnston CommitDate: 2026-11-17 13:24:10 +0000 splice: Fix leaks that can happen when initiating a splice - change the state to SPLICE_EXCEPTION to allow so_unsplice() to work to cleanup failed splices (fixes socket reference leak) - NULL out sp->dst when unsplicing from so_splice() before so2 has been been referenced. - Deal with a null sp->dst / so2 in so_unsplice - Fix asserts that talked about sp->state == SPLICE_INIT; that state is not possible here. Differential Revision: https://reviews.freebsd.org/D54157 Reviewed by: markj Sponsored by: Netflix Fixes: c0c5d01e5374 ("so_splice: Synchronize so_unsplice() with so_splice()") MFC after: 3 days (cherry picked from commit a837d1fe49e0255d81c670dc271ff245ae960097) --- sys/kern/uipc_socket.c | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 2c7467e6f4db..7811e33ad46c 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -1707,6 +1707,10 @@ so_splice(struct socket *so, struct socket *so2, struct splice *splice) error = EBUSY; if (error != 0) { SOCK_UNLOCK(so2); + mtx_lock(&sp->mtx); + sp->dst = NULL; + sp->state = SPLICE_EXCEPTION; + mtx_unlock(&sp->mtx); so_unsplice(so, false); return (error); } @@ -1714,6 +1718,10 @@ so_splice(struct socket *so, struct socket *so2, struct splice *splice) if (so2->so_snd.sb_tls_info != NULL) { SOCK_SENDBUF_UNLOCK(so2); SOCK_UNLOCK(so2); + mtx_lock(&sp->mtx); + sp->dst = NULL; + sp->state = SPLICE_EXCEPTION; + mtx_unlock(&sp->mtx); so_unsplice(so, false); return (EINVAL); } @@ -1780,20 +1788,20 @@ so_unsplice(struct socket *so, bool timeout) SOCK_UNLOCK(so); so2 = sp->dst; - SOCK_LOCK(so2); - KASSERT(!SOLISTENING(so2), ("%s: so2 is listening", __func__)); - SOCK_SENDBUF_LOCK(so2); - KASSERT(sp->state == SPLICE_INIT || - (so2->so_snd.sb_flags & SB_SPLICED) != 0, - ("%s: so2 is not spliced", __func__)); - KASSERT(sp->state == SPLICE_INIT || - so2->so_splice_back == sp, - ("%s: so_splice_back != sp", __func__)); - so2->so_snd.sb_flags &= ~SB_SPLICED; - so2rele = so2->so_splice_back != NULL; - so2->so_splice_back = NULL; - SOCK_SENDBUF_UNLOCK(so2); - SOCK_UNLOCK(so2); + if (so2 != NULL) { + SOCK_LOCK(so2); + KASSERT(!SOLISTENING(so2), ("%s: so2 is listening", __func__)); + SOCK_SENDBUF_LOCK(so2); + KASSERT((so2->so_snd.sb_flags & SB_SPLICED) != 0, + ("%s: so2 is not spliced", __func__)); + KASSERT(so2->so_splice_back == sp, + ("%s: so_splice_back != sp", __func__)); + so2->so_snd.sb_flags &= ~SB_SPLICED; + so2rele = so2->so_splice_back != NULL; + so2->so_splice_back = NULL; + SOCK_SENDBUF_UNLOCK(so2); + SOCK_UNLOCK(so2); + } /* * No new work is being enqueued. The worker thread might be @@ -1833,9 +1841,11 @@ so_unsplice(struct socket *so, bool timeout) sorwakeup(so); CURVNET_SET(so->so_vnet); sorele(so); - sowwakeup(so2); - if (so2rele) - sorele(so2); + if (so2 != NULL) { + sowwakeup(so2); + if (so2rele) + sorele(so2); + } CURVNET_RESTORE(); so_splice_free(sp); return (0);