Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp2299529imc; Tue, 12 Mar 2019 10:54:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqz9yAB4fafiI++AozFFhLCC9AgfoW65v8HWUYvmT3FVdEJquQSOq2WfOhtd+gybG3RCb8Bp X-Received: by 2002:a63:2b03:: with SMTP id r3mr1099525pgr.1.1552413249621; Tue, 12 Mar 2019 10:54:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552413249; cv=none; d=google.com; s=arc-20160816; b=h+LyGNt/Tm7g1ec0HRCfmyU70hnyKbT95pnQAAvxdsQT0X+xxW8eCVOg76W1uKC+Yn RF+Dct4u0SDU4UBXw+ZNHaNqL09CV1xeXTt5iPyndgN5waSsRcfxZXonmAajgjFs3HBB ykZnYCiMklJXW9trqK9x2FJUgVRHSHEnUCP4wwMZHp//0s6k2S41UgAVyeYQXUMPaCey S4tGmBb8lnCBXX1usuxi3/71JZKcgtcnldgCdP7+2Z9uC8G8owsJRZy2kb7oTdUFt098 32wxFtuQ5KtcAK/JAfGGYgQBjV1Qm1jJ7CqpsfkntqHr4GzHM7ftlPzaj2FauvytNORs opNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=rdCNV6fWnL62tj5wdFEHNXWbC5TmTv4NoeDsDiNs/qk=; b=eWPho2Jyp3G5V3/5HJSbXTAYG7CtRf2oK5Qs3FqBziEkMEOtw1aW+7jQa9qhU2tJ8T 0T9zoWnrClrHI+1+w3oLHLO+xLwsEHl7XXqRaVC8z4lhQJuVriVxUSmGOfQEbm+EgapN dqiuBPehHmIcjBbBfLgAeju1pswtcIR3AgzNIKDpXrO93RHFqyWDMzi+wv80ySL22z7F rnt4DAYSMwMZxP6cT7hxo2bYVfGhYfBBT4aGE6tA+A3fOSKlbE0MaJr/gxfP+3iJxLfh e/i6x6sWbnKjkiCflxvfCEguufzjgu0ToOFImmT/cVlyyxIe7uMVBVkszmGfqJF+5IkS HoWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=funZzm9S; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i4si7565228pgs.408.2019.03.12.10.53.53; Tue, 12 Mar 2019 10:54:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=funZzm9S; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728387AbfCLROb (ORCPT + 99 others); Tue, 12 Mar 2019 13:14:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:51236 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728067AbfCLRNq (ORCPT ); Tue, 12 Mar 2019 13:13:46 -0400 Received: from localhost (unknown [104.133.8.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D51C621741; Tue, 12 Mar 2019 17:13:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1552410825; bh=vgqLMyj3R+O1kuqc4IhM5eGrEoTUzu1LfO5Frp0UoHw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=funZzm9Sk7yWgyaVG4iEMbYjUVp1JFeZdbrINlO/JJdt0ElCrOdFRpRA4Ebh/GJc4 ek+ZiNM3CepHMBFVS8nTz0VkzgFm1RQ8WZ+TiJgYVEELKwCKBeDDA8L3afKqw0HsIo 8m6Ceu5GDjHZF8H096y8wFxUCjSDaahsgTEJWry8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Su Yanjun , Steffen Klassert , Sasha Levin Subject: [PATCH 4.19 002/149] vti4: Fix a ipip packet processing bug in IPCOMP virtual tunnel Date: Tue, 12 Mar 2019 10:07:00 -0700 Message-Id: <20190312170349.648360239@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190312170349.421581206@linuxfoundation.org> References: <20190312170349.421581206@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit dd9ee3444014e8f28c0eefc9fffc9ac9c5248c12 ] Recently we run a network test over ipcomp virtual tunnel.We find that if a ipv4 packet needs fragment, then the peer can't receive it. We deep into the code and find that when packet need fragment the smaller fragment will be encapsulated by ipip not ipcomp. So when the ipip packet goes into xfrm, it's skb->dev is not properly set. The ipv4 reassembly code always set skb'dev to the last fragment's dev. After ipv4 defrag processing, when the kernel rp_filter parameter is set, the skb will be drop by -EXDEV error. This patch adds compatible support for the ipip process in ipcomp virtual tunnel. Signed-off-by: Su Yanjun Signed-off-by: Steffen Klassert Signed-off-by: Sasha Levin --- net/ipv4/ip_vti.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c index 7f56944b020f..40a7cd56e008 100644 --- a/net/ipv4/ip_vti.c +++ b/net/ipv4/ip_vti.c @@ -74,6 +74,33 @@ static int vti_input(struct sk_buff *skb, int nexthdr, __be32 spi, return 0; } +static int vti_input_ipip(struct sk_buff *skb, int nexthdr, __be32 spi, + int encap_type) +{ + struct ip_tunnel *tunnel; + const struct iphdr *iph = ip_hdr(skb); + struct net *net = dev_net(skb->dev); + struct ip_tunnel_net *itn = net_generic(net, vti_net_id); + + tunnel = ip_tunnel_lookup(itn, skb->dev->ifindex, TUNNEL_NO_KEY, + iph->saddr, iph->daddr, 0); + if (tunnel) { + if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb)) + goto drop; + + XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip4 = tunnel; + + skb->dev = tunnel->dev; + + return xfrm_input(skb, nexthdr, spi, encap_type); + } + + return -EINVAL; +drop: + kfree_skb(skb); + return 0; +} + static int vti_rcv(struct sk_buff *skb) { XFRM_SPI_SKB_CB(skb)->family = AF_INET; @@ -82,6 +109,14 @@ static int vti_rcv(struct sk_buff *skb) return vti_input(skb, ip_hdr(skb)->protocol, 0, 0); } +static int vti_rcv_ipip(struct sk_buff *skb) +{ + XFRM_SPI_SKB_CB(skb)->family = AF_INET; + XFRM_SPI_SKB_CB(skb)->daddroff = offsetof(struct iphdr, daddr); + + return vti_input_ipip(skb, ip_hdr(skb)->protocol, ip_hdr(skb)->saddr, 0); +} + static int vti_rcv_cb(struct sk_buff *skb, int err) { unsigned short family; @@ -435,6 +470,12 @@ static struct xfrm4_protocol vti_ipcomp4_protocol __read_mostly = { .priority = 100, }; +static struct xfrm_tunnel ipip_handler __read_mostly = { + .handler = vti_rcv_ipip, + .err_handler = vti4_err, + .priority = 0, +}; + static int __net_init vti_init_net(struct net *net) { int err; @@ -603,6 +644,13 @@ static int __init vti_init(void) if (err < 0) goto xfrm_proto_comp_failed; + msg = "ipip tunnel"; + err = xfrm4_tunnel_register(&ipip_handler, AF_INET); + if (err < 0) { + pr_info("%s: cant't register tunnel\n",__func__); + goto xfrm_tunnel_failed; + } + msg = "netlink interface"; err = rtnl_link_register(&vti_link_ops); if (err < 0) @@ -612,6 +660,8 @@ static int __init vti_init(void) rtnl_link_failed: xfrm4_protocol_deregister(&vti_ipcomp4_protocol, IPPROTO_COMP); +xfrm_tunnel_failed: + xfrm4_tunnel_deregister(&ipip_handler, AF_INET); xfrm_proto_comp_failed: xfrm4_protocol_deregister(&vti_ah4_protocol, IPPROTO_AH); xfrm_proto_ah_failed: -- 2.19.1