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: stable@vger.kernel.org Reported-by: Vega Signed-off-by: Zihan Xi --- 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 4052ae5bbb2e..ec37a32ecb00 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.43.0