From: Zihan Xi <ziha…@nebusec.ai> An IPv6 socket can accept an IPv4 connection through a v4-mapped address. Such a socket still receives IPv4 skbs, but espintcp selected the XFRM receive path from the socket family. Use the skb protocol when selecting the receive path so IPv4 packets are not passed to the IPv6 XFRM parser. Fixes: 26333c37fc28 ("xfrm: add IPv6 support for espintcp") Cc: stab…@vger.kernel.org Reported-by: Vega <ve…@nebusec.ai> Signed-off-by: Zihan Xi <ziha…@nebusec.ai> Signed-off-by: Steffen Klassert <stef…@secunet.com> --- net/xfrm/espintcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/xfrm/espintcp.c b/net/xfrm/espintcp.c index 3e23900d6446..8412dc8eeed7 100644 --- a/net/xfrm/espintcp.c +++ b/net/xfrm/espintcp.c @@ -48,7 +48,7 @@ static void handle_esp(struct sk_buff *skb, struct sock *sk) } local_bh_disable(); #if IS_ENABLED(CONFIG_IPV6) - if (sk->sk_family == AF_INET6) + if (skb->protocol == htons(ETH_P_IPV6)) xfrm6_rcv_encap(skb, IPPROTO_ESP, 0, TCP_ENCAP_ESPINTCP); else #endif
-- 2.53.0