Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp5457990imm; Tue, 16 Oct 2018 10:31:20 -0700 (PDT) X-Google-Smtp-Source: ACcGV627hmycukmCJfxXtuU6U1Z6kACme90LdlgNNsqGJaj+nAy45FoKMZ4Pk5NGkSuyFjn8zxYG X-Received: by 2002:a63:510a:: with SMTP id f10-v6mr20853578pgb.31.1539711080038; Tue, 16 Oct 2018 10:31:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539711080; cv=none; d=google.com; s=arc-20160816; b=QtuML/QNlbHeeJAyqE5ARemLrxpBdpQ7wAliT7NS55dQZiSlEfs0uR8bDTXWsqi8Zv g4/cgQVc5x2akIHEHi/5vHIPUi5KJYACYWtPo9eo5lx5Lu/Bss+2qCSLUsLWlDrlvvX3 RrwsGaohdzFsh3pEufbDnyaBCXuyFj46QWGptoAyGapK5GSTrjn1FooCIM2JVhUH8G7e q21K98UqO8huuNbqQx792wbXfJOKzCowOkZykkSlWKhi8olaE7jAUq91BXEd/B+DRTMX CJ8qcRbtz3iNqufwdZduonTh5+WA+OgSesPQIod7Seg8bF/S+WdQxKQfZBuWDsM/m2n7 UL2w== 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=dXrrq+axtZQRaYhrJDjLSWnEVHHY51IHRBXODZiRg34=; b=n6xGlukxfMpjyn07rZLAXUf7p6f/G3Y6yJGXr3UCck5K81GNOf817jWQslPZNWNH40 bjq3Qxm8uY1SD/g/EH17ofSvcWncVzloGS0QHfdiYGnczwHT8ibcILOGsDbZVCoMqDsS vaWnWgYnrWeQdMflsa4IEslnrRnSD+uXtGBRRF9m/LI8nHv2TasSHCMZuhdzpnUb9Ahs DDCQq3mytTHe5mCx0kGC7LKebu5qysb6+PRJJLPxfCFko2j6vCNXbN5REutINXKwBd38 tbsjmRPTAccSlLsh5CNibcKiRN1I3d7A2N1PBmZ3cNbOQjs6rJ69D8Boopp7W8M8bRo8 GCEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ak9xqgSO; 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 q143-v6si13538043pgq.483.2018.10.16.10.31.04; Tue, 16 Oct 2018 10:31:19 -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=ak9xqgSO; 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 S1731413AbeJQBOx (ORCPT + 99 others); Tue, 16 Oct 2018 21:14:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:33378 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730397AbeJQBOx (ORCPT ); Tue, 16 Oct 2018 21:14:53 -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 929E320866; Tue, 16 Oct 2018 17:23:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539710608; bh=iHnQhHcAhED/C7CetQCqAdOCOZ+lHa9P3lUu5ggZ/bE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ak9xqgSODf09EkfgZ0pW96gz/yEgsNSoK4VT3dB5hwrImsXm7PFQPzxqVT9tf+FH+ 3Wt1UQgVYZButIyroINlMi5hFRtmiGt0WQJ18pjsJSXEI5Y6YvqsRcTiwkXP1D/Gfp FZadm0Msmk5aPVYz3K+pNbiGpBOpaoNQxPcsj41E= 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.9 25/71] ip_tunnel: be careful when accessing the inner header Date: Tue, 16 Oct 2018 19:09:22 +0200 Message-Id: <20181016170540.656927872@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181016170539.315587743@linuxfoundation.org> References: <20181016170539.315587743@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.9-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 @@ -627,6 +627,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; @@ -636,6 +637,14 @@ void ip_tunnel_xmit(struct sk_buff *skb, __be32 dst; 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);