Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3787554ybi; Mon, 29 Jul 2019 12:37:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqzXjqYR34Jtdi3GGPfosXhi+JHnHDpjMfmsORwd8SyyUeQtznkEdqwUyFSVSg+kzJr4Ojsw X-Received: by 2002:a17:902:ba96:: with SMTP id k22mr114394989pls.44.1564429036413; Mon, 29 Jul 2019 12:37:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564429036; cv=none; d=google.com; s=arc-20160816; b=QKY6O1wz8ieTJnCpVPDNpJup4fQQEQPiUcJpQW6YMS9BjlUd1yDngOovJY+0NvzcCa o9C6YkKhqr0eMHOb2yGmP6t21ac3eLuztOETjWaMBT/HyfTpUJcTReGXMLg2tsYI2pcc ffeK6gLKmKwTocxsmiwBprWPMMHn4bl+cr6uWkOhJuL4xjZXLy7hCVEhSB38Bf9y1MI5 HEz0kUfUOD2CvGga8iX1z/qaMetudjlgMXxyv+WzHc0/0TXa9fdak9ZnLPIxVBdhftUd 3mEvt6X/4BXN1aW1fDCBqTXr6rf4B58CZiWBztHK7h+GLXC6CCGaiSnil4kBN2RbXgX2 pKoQ== 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=g0tCoUL4ttBboMLMymRA/TkjQJPXzvI+1kJEq8XuxUo=; b=rvnMVnofPIZvtgwWoNmaL3nkgJnQ35IPotZLCFOGRiAn6LGrmAtCHkba6jSGhNyFiW 2YssO9/gv9+GzEgs/4Tqvpipai7w8YjtfrwgkBMDhU0uiXDhDcNhJeIDLk1OcJzKnPVT DOBqx5cL9gijk2lohApoVJ5HDCv8i9Nb9h6nJRmvb9cB4brSQoHh/V6LKq741Eb/S7BG dd5yOdWpHLj+QHMK8rGBpjc+brNJVCvrPyUT6mEf0F6/VHqyGmYdL2CrehqHbJY2XZRT KWcccG4IbHQJK4DEplY2fLecW7M3LFhVIDP3oWNhoxznjxjU1+kYaQVhEEr+8gSxFBoA 9qQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DguS15cK; 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 y6si27716607pfl.288.2019.07.29.12.37.01; Mon, 29 Jul 2019 12:37:16 -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=DguS15cK; 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 S1729067AbfG2Tfi (ORCPT + 99 others); Mon, 29 Jul 2019 15:35:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:49914 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729752AbfG2Tfe (ORCPT ); Mon, 29 Jul 2019 15:35:34 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 D2BEC2171F; Mon, 29 Jul 2019 19:35:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564428933; bh=o+gUEAdqo4k1GnCYrjiQ2VeC9eCNVj157bg/jRvCF7M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DguS15cK8os6vITSHrPZZrxabW5PYmtE9UcqrKWNAlupvKzPrme9M3G+T902UOtaN WMxNlnTA1B63P7lOXeOol2L8nlMmOzhvbUSitRO3WbxzwENWGUOrhtpMtPwBKvhp6n mPTgFA3engyyp5b/BMi+2+U+PYlAfmgp2nv4jQ/A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peter Kosyh , David Ahern , "David S. Miller" Subject: [PATCH 4.14 193/293] vrf: make sure skb->data contains ip header to make routing Date: Mon, 29 Jul 2019 21:21:24 +0200 Message-Id: <20190729190839.257346175@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190820.321094988@linuxfoundation.org> References: <20190729190820.321094988@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Peter Kosyh [ Upstream commit 107e47cc80ec37cb332bd41b22b1c7779e22e018 ] vrf_process_v4_outbound() and vrf_process_v6_outbound() do routing using ip/ipv6 addresses, but don't make sure the header is available in skb->data[] (skb_headlen() is less then header size). Case: 1) igb driver from intel. 2) Packet size is greater then 255. 3) MPLS forwards to VRF device. So, patch adds pskb_may_pull() calls in vrf_process_v4/v6_outbound() functions. Signed-off-by: Peter Kosyh Reviewed-by: David Ahern Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/vrf.c | 58 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 23 deletions(-) --- a/drivers/net/vrf.c +++ b/drivers/net/vrf.c @@ -167,23 +167,29 @@ static int vrf_ip6_local_out(struct net static netdev_tx_t vrf_process_v6_outbound(struct sk_buff *skb, struct net_device *dev) { - const struct ipv6hdr *iph = ipv6_hdr(skb); + const struct ipv6hdr *iph; struct net *net = dev_net(skb->dev); - struct flowi6 fl6 = { - /* needed to match OIF rule */ - .flowi6_oif = dev->ifindex, - .flowi6_iif = LOOPBACK_IFINDEX, - .daddr = iph->daddr, - .saddr = iph->saddr, - .flowlabel = ip6_flowinfo(iph), - .flowi6_mark = skb->mark, - .flowi6_proto = iph->nexthdr, - .flowi6_flags = FLOWI_FLAG_SKIP_NH_OIF, - }; + struct flowi6 fl6; int ret = NET_XMIT_DROP; struct dst_entry *dst; struct dst_entry *dst_null = &net->ipv6.ip6_null_entry->dst; + if (!pskb_may_pull(skb, ETH_HLEN + sizeof(struct ipv6hdr))) + goto err; + + iph = ipv6_hdr(skb); + + memset(&fl6, 0, sizeof(fl6)); + /* needed to match OIF rule */ + fl6.flowi6_oif = dev->ifindex; + fl6.flowi6_iif = LOOPBACK_IFINDEX; + fl6.daddr = iph->daddr; + fl6.saddr = iph->saddr; + fl6.flowlabel = ip6_flowinfo(iph); + fl6.flowi6_mark = skb->mark; + fl6.flowi6_proto = iph->nexthdr; + fl6.flowi6_flags = FLOWI_FLAG_SKIP_NH_OIF; + dst = ip6_route_output(net, NULL, &fl6); if (dst == dst_null) goto err; @@ -239,21 +245,27 @@ static int vrf_ip_local_out(struct net * static netdev_tx_t vrf_process_v4_outbound(struct sk_buff *skb, struct net_device *vrf_dev) { - struct iphdr *ip4h = ip_hdr(skb); + struct iphdr *ip4h; int ret = NET_XMIT_DROP; - struct flowi4 fl4 = { - /* needed to match OIF rule */ - .flowi4_oif = vrf_dev->ifindex, - .flowi4_iif = LOOPBACK_IFINDEX, - .flowi4_tos = RT_TOS(ip4h->tos), - .flowi4_flags = FLOWI_FLAG_ANYSRC | FLOWI_FLAG_SKIP_NH_OIF, - .flowi4_proto = ip4h->protocol, - .daddr = ip4h->daddr, - .saddr = ip4h->saddr, - }; + struct flowi4 fl4; struct net *net = dev_net(vrf_dev); struct rtable *rt; + if (!pskb_may_pull(skb, ETH_HLEN + sizeof(struct iphdr))) + goto err; + + ip4h = ip_hdr(skb); + + memset(&fl4, 0, sizeof(fl4)); + /* needed to match OIF rule */ + fl4.flowi4_oif = vrf_dev->ifindex; + fl4.flowi4_iif = LOOPBACK_IFINDEX; + fl4.flowi4_tos = RT_TOS(ip4h->tos); + fl4.flowi4_flags = FLOWI_FLAG_ANYSRC | FLOWI_FLAG_SKIP_NH_OIF; + fl4.flowi4_proto = ip4h->protocol; + fl4.daddr = ip4h->daddr; + fl4.saddr = ip4h->saddr; + rt = ip_route_output_flow(net, &fl4, NULL); if (IS_ERR(rt)) goto err;