For tunnel mode states, xfrm_state_ok() compares the outer addresses with the template using the family of the inner packet instead of the encapsulation family. The kernel generated states already use tmpl->encap_family here. With IPv6 in an IPv4 tunnel this compares all 16 bytes, so any garbage after the IPv4 address makes the check fail. This happens e.g. with strongSwan after MOBIKE moves an SA from IPv6 to IPv4, and all inbound packets of the SA are dropped. Fixes: 76b3f055f389 ("[IPSEC]: Add encapsulation family.") Signed-off-by: Tomas Paukrt <toma…@email.cz> --- net/xfrm/xfrm_policy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index d2e938d4db9a..de1736b745e6 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c @@ -3399,7 +3399,7 @@ xfrm_state_ok(const struct xfrm_tmpl *tmpl, const struct xfrm_state *x, (tmpl->allalgs || (tmpl->aalgos & (1<<x->props.aalgo)) || !(xfrm_id_proto_match(tmpl->id.proto, IPSEC_PROTO_ANY))) && !(x->props.mode != XFRM_MODE_TRANSPORT && - xfrm_state_addr_cmp(tmpl, x, family)) && + xfrm_state_addr_cmp(tmpl, x, tmpl->encap_family)) && (if_id == 0 || if_id == x->if_id); }
-- 2.43.0