From nobody Mon Nov 09 15:31:37 2026 X-Original-To: dev-commits-src-main@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 4jNYff59Stz6yxWq for ; Mon, 09 Nov 2026 15:31:38 +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 4jNYfd7472z4S82 for ; Mon, 09 Nov 2026 15:31:37 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794238298; 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=Hq8FOgGbw5xFUXPbcO4AHBeIFJ1UoLTQ8OTov0tbvEE=; b=qW7SFSk10jO1GlCMf7JtSxmH87upkBjXk2BGNn+8csSExyA+als7WodTAi3T264Wlx1AYa XJKqUMiqwpuhdAWqNqAG5X55BovKvZi7u+ktEtRO0Mr/OZpa03gZyCdc+Lez1gU5he3cwW 0Pk9aNeVqVwKnd/PLcG4YX/fHbT2QcpidOhdjoTpnwuFboimIHT+aY+oTqGR8VmWW3FVuo Sl2U4aXo1uhlvaZdgDGjpRMta61DRyqaXYHWI4d5mRWCEcF8gYMDZhwcyfta7mQcCvo0b0 zo1QlFW+5puYrVc5WBMihrWRshO77veXWSloHUBWEyNaCeyYuJyq6Zbgpa94Zw== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794238298; b=Iz0D02W+/rh5qJkvMfx8VIx4CJcFhNvHjvYWAg+i0Kulp0Qxxx8SzbVpOM5J7+iVmHWaPC dhrEQD3Cr+NV89QnipWP+ikebJ25voLSfCNNbelTNdZVsS3NZ8L2RMo2Nlw51SFLKc3z7Y RrIxN7VjgQW7OYgc52iK00WKKsscJ7HsZtWG5skXvX4ap6roJI34cBtYk6EdXkSCl7wUrb deBYza/qbbGAdZGWiu3h7CiH4lu992inUs3oxxh9MtYKTvAUG5iIcVlWFBhjc7Yo0ERCsl N2RRmR0f4W71FayTXYVRfxp4G1YR00nf9kT24wFHzr/vx9Twm7ODgm8ZhL2mcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794238298; 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=Hq8FOgGbw5xFUXPbcO4AHBeIFJ1UoLTQ8OTov0tbvEE=; b=Pi+oJNkzoRj24qNY0DMdG0PtAcbIYQE/nVpcEH01q7HO8AMwCgNDClxOhz1AMWBZcjGynL 2RPZJa/GVxjwb2tUldl4lVhw0BdSPF0uyXO0xrVU7oG8ecasxrmbh5RW1K+rdZdNeJq3GZ IKlheONGZ1nyQf9fmJEoFT/bEUQQpn1fIH1Yu+blM1od2RVxUcc6pvy29ZIYIHlQDqDJ0O 6oqummV+AUAkBOmULJfbUw587oUkvMsVVqDg6mQP1Ejh/0iei6aW3qYtF+6t23IgQ9tbdN 5n5bmMie6A7524FPhoiWq5Q504fuXZt3/Ld4i3X8ekGegw09USZ2rKBFl4k94Q== 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 4jNYfd6kvpzn0Y for ; Mon, 09 Nov 2026 15:31:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1e4a7 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 09 Nov 2026 15:31:37 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: R. Christian McDonald Subject: git: 488bf4473772 - main - netipsec: Do not leak the SAH when an SA is cloned List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org List-Id: Commit messages for the main branch 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: 488bf44737722c27f2e93b5347648e76e86540df Auto-Submitted: auto-generated Date: Mon, 09 Nov 2026 15:31:37 +0000 Message-Id: <6af1e759.1e4a7.ee9fef1@gitrepo.freebsd.org> The branch main has been updated by rcm: URL: https://cgit.FreeBSD.org/src/commit/?id=488bf44737722c27f2e93b5347648e76e86540df commit 488bf44737722c27f2e93b5347648e76e86540df Author: R. Christian McDonald AuthorDate: 2026-11-09 15:30:12 +0000 Commit: R. Christian McDonald CommitDate: 2026-11-09 15:30:12 +0000 netipsec: Do not leak the SAH when an SA is cloned key_updateaddresses() gives the clone of an SA a new SAH reference when the SA index comes from key_newsah() or key_getsah(), but nothing releases the reference of the old SA: key_delsav() leaves the SAH alone, because key_unlinksav() normally releases it, and an SA that is replaced never goes through that. The SAH then stays allocated for good, after its SAs are flushed and after the vnet is destroyed, as an SADB_UPDATE with a new address does each time an IKE daemon moves an SA. The old SA cannot release the reference when it is replaced, since a sender that still holds it reads its SAH. Release it in key_delsav() instead. When only the NAT-T config changes, the clone used to take over the reference of the old SA; take a new one in that case as well, so that every SA holds its own. Reviewed by: kib, markj MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D61101 --- sys/netipsec/key.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sys/netipsec/key.c b/sys/netipsec/key.c index 06cb748bf2a7..a2563689798f 100644 --- a/sys/netipsec/key.c +++ b/sys/netipsec/key.c @@ -3284,7 +3284,8 @@ key_delsav(struct secasvar *sav) rm_destroy(sav->lock); free(sav->lock, M_IPSEC_MISC); uma_zfree_pcpu(ipsec_key_lft_zone, sav->lft_c); - } + } else + key_freesah(&sav->sah); #ifdef IPSEC_OFFLOAD /* XXXKIB should this be moved to key_cleansav()? */ uma_zfree_pcpu(ipsec_key_lft_zone, sav->accel_lft_sw); @@ -5504,9 +5505,12 @@ key_updateaddresses(struct socket *so, struct mbuf *m, } /* * isnew == 1 -> @sah was referenced by key_getsah(). - * isnew == 0 -> we use the same @sah, that was used by @sav, - * and we use its reference for @newsav. + * isnew == 0 -> we use the same @sah, that was used by @sav. + * @sav keeps its own reference until key_delsav(): a sender that + * still holds @sav reads its SAH. */ + if (isnew == 0) + SAH_ADDREF(sah); SECASVAR_WLOCK(sav); /* XXX: replace cntr with pointer? */ newsav->cntr = sav->cntr;