Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3001888imu; Sun, 9 Dec 2018 14:48:38 -0800 (PST) X-Google-Smtp-Source: AFSGD/UFUEusZ2CLJrNuu5TgXSMNU1AUp9r0Dc8l8f4Hb9ts60JYIxMhMBPpluSarKytB+hHoUjV X-Received: by 2002:a17:902:20c8:: with SMTP id v8mr10077972plg.319.1544395718244; Sun, 09 Dec 2018 14:48:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544395718; cv=none; d=google.com; s=arc-20160816; b=Z6asUOn2kRWB4dRSN/8ld0oAPGjn+WkZJm/JIV2/Ax7ibazRbWqNqtXiDiCUiQ1492 uaGuzL3p5T7W6oFrSb+9KBWNMYBcamGDbGBe1Yo84izYM0VE2vFvEkSZ3OKz4J3cMeao CKBLT0LAHN5UaJMEVGTl7lXBnMEhRs8Jw/p4H8WfYH6h3ucFJDf+lhY8uVASRQkjjmQo 88BA1F00voT/0argO4DZYAFmDjOOoMAwYhdMqISF9UE3vD7p/591F9RRnshSsMH5MnXR TX1pttPTd2vQ8H3pExsheoThXEhRBB9Dihe81balavQWBkb8++fhH8qCbpeFn/zZ2avx kQ9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=9nFwsz2qeDWSICAN4Cwc+hT98T9AvFc2p6z1NGHy3kg=; b=vO69g6y7lDEhmLwAjfOxzGfaUBCdLKOrdzrui59/gbfLBN+dTLCTdky2v/+Jw7SQDQ H1t23xWI872uUzfhrcNd6E5TGfweIJ0OJlOXE8VvDNINo2d49CKZSX8dOtixClvmRqm3 8s+ulI+G+coSK7siNUrjtUGiUi4Wa+JXB+9oSBF2d7Nm5r9r4J7/rNE4wAm9T6jibXLN oqkF1w3ACXtX438Ep6Ou63cK8Jx2HkzQuKnEZeENkzgCWdPKIcXCqBPMmPUm2wYWzxeW g+5ShHg/4oS69Rqr/oXJ4QIqmJX+NQVDSAion7krPO9wZXNrp1gbGC0E8Sv8mUQplSkw eX0g== ARC-Authentication-Results: i=1; mx.google.com; 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 k18si8611499pgf.97.2018.12.09.14.48.23; Sun, 09 Dec 2018 14:48:38 -0800 (PST) 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; 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 S1727230AbeLIWBO (ORCPT + 99 others); Sun, 9 Dec 2018 17:01:14 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:35972 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726686AbeLIVze (ORCPT ); Sun, 9 Dec 2018 16:55:34 -0500 Received: from pub.yeoldevic.com ([81.174.156.145] helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gW72x-0002iY-E6; Sun, 09 Dec 2018 21:55:31 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gW72j-0003bR-5L; Sun, 09 Dec 2018 21:55:17 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Cong Wang" , "Paolo Abeni" , "David S. Miller" Date: Sun, 09 Dec 2018 21:50:33 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 263/328] ip_tunnel: be careful when accessing the inner header In-Reply-To: X-SA-Exim-Connect-IP: 81.174.156.145 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.62-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Paolo Abeni commit ccfec9e5cb2d48df5a955b7bf47f7782157d3bc2 upstream. 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: Ben Hutchings --- net/ipv4/ip_tunnel.c | 9 +++++++++ 1 file changed, 9 insertions(+) --- a/net/ipv4/ip_tunnel.c +++ b/net/ipv4/ip_tunnel.c @@ -551,6 +551,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, const struct iphdr *tnl_params, const 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; @@ -561,6 +562,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);