Commit 92811d419d for strongswan.org

commit 92811d419db848a9915cfa6828b047d37d35ad41
Author: Tomas Paukrt <tomaspaukrt@email.cz>
Date:   Sun Nov 29 20:56:25 2026 +0100

    kernel-netlink: Clear complete address when converting to xfrm_address_t

    When converting addresses, only as many bytes as the address actually has
    are copied, so for IPv4 just the first 4.  This is fine for new messages
    that are zeroed, but when updating an SA we start with a copy of the
    existing one from the kernel.  So if MOBIKE switches the SA from IPv6 to
    IPv4, the new IPv4 addresses still contain the rest of the old IPv6
    addresses.

    The kernel uses the family of the policy when it compares the addresses
    of an SA with the template of a policy.  With IPv6 traffic selectors all
    16 bytes are compared, so the updated SA doesn't match the inbound
    policy anymore and all decrypted packets are silently dropped.

    Newer kernels that support XFRM_MSG_MIGRATE_STATE are not affected as
    the request is zeroed there, but the fallback that deletes and re-adds
    the SA (older kernels or if the migration fails) still has the issue.

    Closes strongswan/strongswan#3220

diff --git a/src/libcharon/plugins/kernel_netlink/kernel_netlink_ipsec.c b/src/libcharon/plugins/kernel_netlink/kernel_netlink_ipsec.c
index 0236d2073d..b8637658ef 100644
--- a/src/libcharon/plugins/kernel_netlink/kernel_netlink_ipsec.c
+++ b/src/libcharon/plugins/kernel_netlink/kernel_netlink_ipsec.c
@@ -819,6 +819,8 @@ static uint8_t mode2kernel(ipsec_mode_t mode)
 static void host2xfrm(host_t *host, xfrm_address_t *xfrm)
 {
 	chunk_t chunk = host->get_address(host);
+
+	memset(xfrm, 0, sizeof(xfrm_address_t));
 	memcpy(xfrm, chunk.ptr, min(chunk.len, sizeof(xfrm_address_t)));
 }

@@ -854,6 +856,7 @@ static void ts2subnet(traffic_selector_t* ts,

 	ts->to_subnet(ts, &net_host, mask);
 	net_chunk = net_host->get_address(net_host);
+	memset(net, 0, sizeof(xfrm_address_t));
 	memcpy(net, net_chunk.ptr, net_chunk.len);
 	net_host->destroy(net_host);
 }