From nobody Tue Nov 17 17:04:16 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 4jTWKr6F1yz71R24 for ; Tue, 17 Nov 2026 17:04:16 +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 4jTWKr2wRjz4Fj0 for ; Tue, 17 Nov 2026 17:04:16 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794935056; 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=ubfLBJV7jnBw/5xmW0lGOJC5r+3bM3HYGgEfRKfUYiI=; b=qer2fXoIdW8e39ACs6UK0SfIWPLuEraa8EfWMK+rLbKRBMIX4RP2yAjx+O8xnY7zKM4MDd gfJVDIVdVKJx15Cwv9ujFHSqiFxtZ43tQSVVTkIqantn+OxLpnkTd5dzJM/zodd/fg+jVx 32I2VSl8zKzNI8qqKppVtngixNDtHTMpBF+EjDj/Rl9FN/lZmNF9yt8DUXDuFVuNl0VfHC b/0+TpdWKf7meEvf1Kkwx5Oun4AVIHrdM4JNlhnd3l22RE5bAe4mgBu3fIYir7aI4Np94h SfDUA3NjuIF544d3uCpLdjuPmHTfZ7kMPanBlpUGerjPYrL6I6Ul9Hk3UZJbqw== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794935056; b=Nlgc41Ulztx4+HW0kyQD6f6SpkHXxuvOYfYBXkBreG1mZuIWHC67itCIm8q2gfr40W/sIP sBx0AT/9dE5PXWuBaXinGKa0rApJ5E/SnbGjZ/uGgubGzXOIbXktwbQWZwJtLp4wTwHYbK z+Ti183wAPfsLarwxRUtlOJnCUHMqJkD+3V57SW8H14XKmT1Hpueot/ui4Ql20EOwU4CsR kMsEGVl0Cw7TuIhddrw4pa2L2dPOY0XrPEJjpPc4bR2XNSvr7bAQCvQg0MIVK+rsFBHFeo DypdzyN1IIJN4m6s3+4RHuC1wC4qgFJmJWP2frfgkKxYmM50AtzAb0xDaloang== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794935056; 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=ubfLBJV7jnBw/5xmW0lGOJC5r+3bM3HYGgEfRKfUYiI=; b=b+tIE4VlosufnxJv1Fhb9sRRlhM34B47kJsrQCGImBNsJZFOlrHv9g9SMvqWEOXkOYCEnO 19i4aTxvI6vAsaN+OPmpnaqLh/8qm2KDaFm3ZEq1egYlWJJ/aD/wuUh2FZIsDv7tSxC+aJ yPiWXiU54vw4FuWOEEp3Bve6NbobHgiz4JysGi/IaWN8SsgYrdk5Xekedw/mjHgEL5Sazz sSZPnt/Bq5FdbXUcPjPnnBGf/q+M8FtpP4ytq0YXBagqb3Bdx+NngpI1wb5TSbH1eT8B6n UIq7JmBE8OFR9TgoJ2eqJeX/XDthPAetOC5iX8mIBQDlSq6RujZdLzAfwtHrMw== 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 4jTWKr2b9bzr8n for ; Tue, 17 Nov 2026 17:04:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1f58b by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 17 Nov 2026 17:04:16 +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: 97c2c8dac5e7 - releng/14.4 - 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/releng/14.4 X-Git-Reftype: branch X-Git-Commit: 97c2c8dac5e7fa099aa9dd7dd08fa52f574732dd Auto-Submitted: auto-generated Date: Tue, 17 Nov 2026 17:04:16 +0000 Message-Id: <6afc8910.1f58b.58d9b2d2@gitrepo.freebsd.org> The branch releng/14.4 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=97c2c8dac5e7fa099aa9dd7dd08fa52f574732dd commit 97c2c8dac5e7fa099aa9dd7dd08fa52f574732dd Author: Andrew Gallatin AuthorDate: 2025-12-09 21:06:20 +0000 Commit: Mark Johnston CommitDate: 2026-11-16 21:16:22 +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. Approved by: so Security: FreeBSD-SA-26:87.socket 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 74edbbb1b0a4..f9ce5446f459 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -1701,6 +1701,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); } @@ -1708,6 +1712,10 @@ so_splice(struct socket *so, struct socket *so2, struct splice *splice) if (so->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); } @@ -1774,20 +1782,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 @@ -1827,9 +1835,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);