git: 698d94219061 - main - netipsec: Release the SA and SP when mb_unmapped_to_ext() fails
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 16 Nov 2026 15:18:02 UTC
The branch main has been updated by rcm:
URL: https://cgit.FreeBSD.org/src/commit/?id=698d94219061eaca8dd5fd4d58bbece48ced3ac4
commit 698d94219061eaca8dd5fd4d58bbece48ced3ac4
Author: R. Christian McDonald <rcm@FreeBSD.org>
AuthorDate: 2026-11-16 15:16:55 +0000
Commit: R. Christian McDonald <rcm@FreeBSD.org>
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;