From nobody Mon Nov 16 15:18:02 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 4jSs1l3krGz70rRB for ; Mon, 16 Nov 2026 15:18:03 +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 4jSs1l0mwGz4RWk for ; Mon, 16 Nov 2026 15:18:03 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794842283; 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=oN8ifbu1VoJtU88ZaIqXIHXreSXJdJS5s+jxGnkdEsE=; b=BViuk2p2WVHV+0m9QyVGSvKEOCxcngYp7FetIeOm2VN6whlsrsXEeD8sPXiBwOD+wREa9u yCej4otOJzUqMrXpFV9BQO9CfO/bo91hBSnomU///VXAJj0hGyAmoSYRd1SVUzVM6Xi9/5 wg0t/M6RF9ztE0GDNxORhmPQQFmejWifGdHkU18O9rnhKjFPppg5ORkrzThMY0rJohsL50 d5JPM3u6kHG4kz0xX7Xk/WhpHD9epkHycKc3Bmum9ykBwAhNDnynd5GRNBVdapLu3TggsL IQ/GIFZTUUVsChEbtFke7vOm4LRXAn5NmllWn7kUnM3xdiT2F4C7us66fjJSxA== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794842283; b=CNbiGzb3AocIw30DtqfKSmcdnqXjN62mZ6/F/0pG6e1PzJAXvdBzD5RyWAb4mMqA4T+EGg CCS/NAse7bpcVX/fedfgRVxqMD5aF+Fa825KEkrdYhx3KVHuL1CLK2EC+vbj57wuRc7Cl4 JqsljZKyNY2eDDiMjtkgQ/S1uWt9jEw/x6BJ1QaNl/MSg9/7+6ebwon6rCQXZkw+c/SQVK nP686qAnsctQtsRC/CJGMjwrIjqX3Wrf65/O7pxt8/wf0BxsBxknv6eViUwaelPGLumAvT hdtYnt6XWulg/4aUcmWU5Sy0Rpy9OsFKPxB9SkD9aHHPXDgHA8L+jcG+xl+sZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794842283; 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=oN8ifbu1VoJtU88ZaIqXIHXreSXJdJS5s+jxGnkdEsE=; b=T2Rel11GI0RZFLjk4ozYJYxtAh/xdrtL8dy0eVL8CjjNnmC00wZJbxnpIjRMqwDdIKRWWc eJcjUc20DZg/D0BNOTUup9nLp/6JngM/YLa4eK5B+O+QkoESkNNavwITwDfGdKTiUxfCGI I/z3nTBVMDYPqotjxfiVWDX0dClbJGewpdRSr6dtaFvkbU83w/X2JLh2IljlTKF50t16Wv qbCsf9vKonBD0YlosqN2lGNBqMcvmPkmyKJ45olvbfHoGChxbNBtMaebKhH2vE9JPDG3wt lbTDCBPobKziyoR9p4Rru00qhwC+gfG60ySnChLDsADQS6WyfM8au3/QJg0smw== 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 4jSs1k6xg8z10DH for ; Mon, 16 Nov 2026 15:18:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 334e by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 16 Nov 2026 15:18:02 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: R. Christian McDonald Subject: git: 698d94219061 - main - netipsec: Release the SA and SP when mb_unmapped_to_ext() fails 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: rcm X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 698d94219061eaca8dd5fd4d58bbece48ced3ac4 Auto-Submitted: auto-generated Date: Mon, 16 Nov 2026 15:18:02 +0000 Message-Id: <6afb1eaa.334e.73c41fc8@gitrepo.freebsd.org> The branch main has been updated by rcm: URL: https://cgit.FreeBSD.org/src/commit/?id=698d94219061eaca8dd5fd4d58bbece48ced3ac4 commit 698d94219061eaca8dd5fd4d58bbece48ced3ac4 Author: R. Christian McDonald AuthorDate: 2026-11-16 15:16:55 +0000 Commit: R. Christian McDonald CommitDate: 2026-11-16 15:17:58 +0000 netipsec: Release the SA and SP when mb_unmapped_to_ext() fails ipsec4_perform_request() maps unmapped (M_EXTPG) mbufs before the software transforms run. mb_unmapped_to_ext() frees the chain when it fails, and the error return then kept both the SA reference taken by ipsec4_allocsa() and the SP reference that this function must release. The SA, its crypto session and the SP were never freed after they were deleted. The conversion fails with ENOMEM when an mbuf allocation fails, for example for sendfile(2) data sent through a software IPv4 SA, and with EINVAL for every packet of a NIC kTLS connection that matches an IPsec policy. Take the common error path instead; it skips m_freem() when the mbuf pointer is NULL. IPv6 is not affected: ipsec6_perform_request() does not call mb_unmapped_to_ext(). Reported by: llm-postcr Fixes: 0ff2d00d2aa3 ("ipsec: allow it to work with unmapped mbufs") MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/netipsec/ipsec_output.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/netipsec/ipsec_output.c b/sys/netipsec/ipsec_output.c index 90f6b634507b..50a34b83e5d0 100644 --- a/sys/netipsec/ipsec_output.c +++ b/sys/netipsec/ipsec_output.c @@ -271,7 +271,9 @@ ipsec4_perform_request(struct ifnet *ifp, struct mbuf *m, struct ip *ip1, if (bootverbose) if_printf(ifp, "Tx TLS+IPSEC packet\n"); } - return (error); + /* mb_unmapped_to_ext() has freed the chain. */ + m = NULL; + goto bad; } m = m1;