Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2438674imm; Thu, 7 Jun 2018 10:34:17 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIbA/SKnXySJrhWolBbAPJwoJruZ2HmzhW3tdQqqCgLZjdcrxoWDgkpJ3BlaTTdQ4sfaRZv X-Received: by 2002:a62:c296:: with SMTP id w22-v6mr2644045pfk.92.1528392857497; Thu, 07 Jun 2018 10:34:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528392857; cv=none; d=google.com; s=arc-20160816; b=AlB2vc2ZYUJx6MOYdvEm3kE//Fcjkfz6bwcmQhCvlkfP74C/0jdvXj81n/Gpsa/jus VBBLtw5dwG6cDlfELXpyi/L1fnIcwuxgSJ8QHzjPtoolKXr+BjbX+FbEAPEXJXnOnt9n HLmWAMA6Qb1r5/uuSGOTRyYou6SooLRuxVz+vsS+NGaEUtRj+wKu7u3MLUvp2D1AKcXD B2kjCoBUlgowLahn7d7r8gUZrqpQ3W7bvJ3GcMa2wI0/2hqKhZn73Y54N1+g+RGkyI5o RHXzAX66k9a7ZhD7JL9cqcLnj9cUJ4Dp7hu/C0TLMZFYP1MJlBgwqK0XQsjGNhMBxIgL NDEg== 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 :arc-authentication-results; bh=tdj6cJ+/X42aljJucttK5Kr7eJYQfaLjKH39TFdpbLE=; b=Y9ZQdlmO41M5FBvdWHAEXiS/7gq/8sQ5i1dvQXghIQRQDyi0omHDk2U8Cr3E2fd2e/ rbDr7PTIc0QO9XGEnOigUeTwzP0FvVgAUQFL9jJjO0QLMMGFPawCX3lfjP/AVRCMTQPU 5ysMBIIJc8CEZiGzlHIeEPY5IgNdqHzWneM9XRt6n133ev5wep9N1txkqUwDVmqG4fNL JN4ukq/HnEIswn3jRNC41R+aAMthEsTjMimockH3CPXqIiy/DhM8jnqAIRSnb4fwSrSH +JEbblTHXtpio/h32obI7asfIms/uDrv/K6pCGe9U/OVTHgU7KRqyrgpaIqtItFiN6hb t40Q== 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 w31-v6si40174240pla.127.2018.06.07.10.34.03; Thu, 07 Jun 2018 10:34:17 -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; 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 S934399AbeFGOkM (ORCPT + 99 others); Thu, 7 Jun 2018 10:40:12 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:40534 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934205AbeFGOkH (ORCPT ); Thu, 7 Jun 2018 10:40:07 -0400 Received: from [148.252.241.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1fQvbN-0005Zw-22; Thu, 07 Jun 2018 15:09:21 +0100 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1fQvbD-0003Gx-Jw; Thu, 07 Jun 2018 15:09:11 +0100 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, "Sabrina Dubroca" , "Steffen Klassert" , "Stefano Brivio" Date: Thu, 07 Jun 2018 15:05:21 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 375/410] ip_tunnel: Clamp MTU to bounds on new link In-Reply-To: X-SA-Exim-Connect-IP: 148.252.241.226 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.57-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Stefano Brivio commit 24fc79798b8ddfd46f2dd363a8d29072c083b977 upstream. Otherwise, it's possible to specify invalid MTU values directly on creation of a link (via 'ip link add'). This is already prevented on subsequent MTU changes by commit b96f9afee4eb ("ipv4/6: use core net MTU range checking"). Fixes: c54419321455 ("GRE: Refactor GRE tunneling code.") Signed-off-by: Stefano Brivio Acked-by: Sabrina Dubroca Signed-off-by: Steffen Klassert [bwh: Backported to 3.16: Add definition of ETH_MIN_MTU] Signed-off-by: Ben Hutchings --- net/ipv4/ip_tunnel.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) --- a/net/ipv4/ip_tunnel.c +++ b/net/ipv4/ip_tunnel.c @@ -968,8 +968,14 @@ int ip_tunnel_newlink(struct net_device eth_hw_addr_random(dev); mtu = ip_tunnel_bind_dev(dev); - if (!tb[IFLA_MTU]) + if (tb[IFLA_MTU]) { + unsigned int max = 0xfff8 - dev->hard_header_len - nt->hlen; + + dev->mtu = clamp(dev->mtu, (unsigned int)ETH_MIN_MTU, + (unsigned int)(max - sizeof(struct iphdr))); + } else { dev->mtu = mtu; + } ip_tunnel_add(itn, nt); --- a/include/uapi/linux/if_ether.h +++ b/include/uapi/linux/if_ether.h @@ -36,6 +36,8 @@ #define ETH_FRAME_LEN 1514 /* Max. octets in frame sans FCS */ #define ETH_FCS_LEN 4 /* Octets in the FCS */ +#define ETH_MIN_MTU 68 /* Min IPv4 MTU per RFC791 */ + /* * These are the defined Ethernet Protocol ID's. */