Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2258013imm; Thu, 18 Oct 2018 11:32:02 -0700 (PDT) X-Google-Smtp-Source: ACcGV60nZ0P5GmN2DP0FBCU5zUmnkX7mDyZLb+KbvskActTkxWm9spPfeSqJD9XSnM0xvEwyPs6G X-Received: by 2002:a62:6c42:: with SMTP id h63-v6mr3654278pfc.176.1539887522534; Thu, 18 Oct 2018 11:32:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539887522; cv=none; d=google.com; s=arc-20160816; b=kR2bjx+QVD2aUFmC3PHS1MIRZfOeS2UYIRj1P4GK3qjW/pfMuhYTMuLMXm/mdAQCWu /Upykb7cdYEz0RYmAhteai1jQdz/zmvI+HLpzFfWiafhn25QsvekKR9fWoF0ar/ibr5O mfeSP7eHcZbprizk4UtufUDk/xuqkJVvOrx2VKUkXSkxM2SbhUmMHDz7nImUAtDFn65z cwZrP97Ct/naSYwVt8ACzPRaYl2FDYxisKLo4IWy4pa0/PE4llcXKUe1UMaciqsAkbnf cX3Thr+9/ThWlgFxNcJ6Pmsjv7sRVAp62I3eKrRaGVU2oD2E3s1rvnBcbMEeq45lhtUf hA5Q== 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=+ZBXKRTEC8/KPBjSx0iQitMcc5vDdJ5CEPVVhivi9VM=; b=Ha482SBnZPMidB6obQqEE0A1lgv3zoBXsQ43+mM/WteKArFXLHkhj4olQw/9TdaiBS +fy+Xoj+AmWRGVKNUDR71MXq2bvnBMTGS37hXzSKA18gvYgs2E+YEVDUU6BC/M6T1vxT Zd+b+WFZry3VW805JhdHnkHBFmF8ZNXv5nlIcl1qTRtZe9tTBJeAedMnS7pAcaTT9jGu m4YBx74F5/dutU/nBJfCoyUvAkANh0+k9GBd4p4D96EpHr86iQHBrwcAXglcbsQeVJFC fC3rfVfeI142vjnSAlY2TtOvVHp2y7ZEvdsCFAAZWv6Cn9gb8ZwLsKOc/oxZc2f4LRCh UB0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HhQ7VzEV; 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 j134-v6si22888742pgc.134.2018.10.18.11.31.47; Thu, 18 Oct 2018 11:32:02 -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=HhQ7VzEV; 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 S1730294AbeJSCHg (ORCPT + 99 others); Thu, 18 Oct 2018 22:07:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:56320 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726599AbeJSCHf (ORCPT ); Thu, 18 Oct 2018 22:07:35 -0400 Received: from localhost (ip-213-127-77-176.ip.prioritytelecom.net [213.127.77.176]) (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 D46F021479; Thu, 18 Oct 2018 18:05:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539885928; bh=VyIGnZnoysgWAfAyhtGyVKOvKhodWh23c3bbSE6NQEk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HhQ7VzEVtqNMEP1pmPlndSZETH6ueBazcy4oQMI8pLLN5mdGsfpnjHNamYv/abmMb XRtTKObI2j3SsZObW7nzTqJiiL8jgzfVlotVWMbmaJN9ULmGXQfzuQdIFbFBSv3pQi u4rFdqBxXEgm6NCEsXdVf6uEYQbvz8MfMGXyXL/4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Cong Wang , Paolo Abeni , "David S. Miller" Subject: [PATCH 4.4 20/48] ip_tunnel: be careful when accessing the inner header Date: Thu, 18 Oct 2018 19:54:55 +0200 Message-Id: <20181018175429.102250702@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181018175427.133690306@linuxfoundation.org> References: <20181018175427.133690306@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Paolo Abeni [ Upstream commit ccfec9e5cb2d48df5a955b7bf47f7782157d3bc2] Cong noted that we need the same checks introduced by commit 76c0ddd8c3a6 ("ip6_tunnel: be careful when accessing the inner header") even for ipv4 tunnels. Fixes: c54419321455 ("GRE: Refactor GRE tunneling code.") Suggested-by: Cong Wang Signed-off-by: Paolo Abeni Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv4/ip_tunnel.c | 9 +++++++++ 1 file changed, 9 insertions(+) --- a/net/ipv4/ip_tunnel.c +++ b/net/ipv4/ip_tunnel.c @@ -597,6 +597,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, const struct iphdr *tnl_params, u8 protocol) { struct ip_tunnel *tunnel = netdev_priv(dev); + unsigned int inner_nhdr_len = 0; const struct iphdr *inner_iph; struct flowi4 fl4; u8 tos, ttl; @@ -607,6 +608,14 @@ void ip_tunnel_xmit(struct sk_buff *skb, int err; bool connected; + /* ensure we can access the inner net header, for several users below */ + if (skb->protocol == htons(ETH_P_IP)) + inner_nhdr_len = sizeof(struct iphdr); + else if (skb->protocol == htons(ETH_P_IPV6)) + inner_nhdr_len = sizeof(struct ipv6hdr); + if (unlikely(!pskb_may_pull(skb, inner_nhdr_len))) + goto tx_error; + inner_iph = (const struct iphdr *)skb_inner_network_header(skb); connected = (tunnel->parms.iph.daddr != 0);