Received: by 10.223.185.116 with SMTP id b49csp825599wrg; Sat, 10 Feb 2018 21:17:59 -0800 (PST) X-Google-Smtp-Source: AH8x225g7hOtD+cS1cc2GkeMJFbJfkw8kF9I+/0lbYIHqFvxjr60tkeOqBWYH+P2XrJjpu/dPAMS X-Received: by 10.99.43.73 with SMTP id r70mr6621263pgr.316.1518326279379; Sat, 10 Feb 2018 21:17:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518326279; cv=none; d=google.com; s=arc-20160816; b=bh2A69peT/VQqz12ZXC9w020h0ctaBPj36rJ4ujTGFn9Z8GRBFD8wnuMmlvyCQnyy3 QTQ/234AFKlJR/VDB3bvI+7QHAa6UPotfc4occVJgzrvIgNahR/nk6KNbMSGZv9r8Jjm BextEQtJxwnH83MXAb7Fy07z6cIoxo8tffIy2G3pNDMQB5Pr5K2qvV//BsJsTUzlPVLk bQUP685zkEAjgyYkRzymSgUxjRbw7Wo1OqLsbQBEY8+U/hsaDwu6Ln0hvRHyd3XUHBEO xyTU0cAkPFXZcdbKyGB9HhylbKbGcjacnmp2iB1ZL26y9RFqQ/FsWs8vFVLIgSimRG5I uZug== 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=d4CyxUmRxpHvn6+dOZlwtgqCrsfSmiBadbzqHAFcg4o=; b=FtaofL6LBY5K6tW54vsA0P9xwUf2305RrrHkfiMGWDBBgu/Qk6prc6utkeP8iP3BVj txRrlIc/J+h+LtSs66lDo+K8JhGoR5QdNv/Aa0rW8GTN/hwi0gvXUrGfMSLu4RgnnYRW yPy5BwfvcU4GDN4UKrsdRXD4o7pVLHLUDG/D3eOFZezYtq5WNrttVIb+hdoAtmYAVhOx 9IeNUII9IWdqglTzY2u/gZ3HioqwVP1jpktQw3cM50ql8xIliqbo7Epor5rX3u1O2uoh ipXYIJzyuNWCDDQfb/BkJFoPgRg+S9o8SIX5JXqjlbd/p5bUie9hpmlfEaymQOMUOEwA qxZA== 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 u18si1940086pge.232.2018.02.10.21.17.45; Sat, 10 Feb 2018 21:17:59 -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 S1753871AbeBKFQz (ORCPT + 99 others); Sun, 11 Feb 2018 00:16:55 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:41360 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752580AbeBKEdl (ORCPT ); Sat, 10 Feb 2018 23:33:41 -0500 Received: from [2a02:8011:400e:2:6f00:88c8:c921:d332] (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 1ekjKd-0002hP-DA; Sun, 11 Feb 2018 04:33:39 +0000 Received: from ben by deadeye with local (Exim 4.90) (envelope-from ) id 1ekjKY-0004WV-M4; Sun, 11 Feb 2018 04:33:34 +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, "Pablo Neira Ayuso" , "Phil Oester" Date: Sun, 11 Feb 2018 04:20:06 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.2 63/79] netfilter: xt_TCPMSS: Fix missing fragmentation handling In-Reply-To: X-SA-Exim-Connect-IP: 2a02:8011:400e:2:6f00:88c8:c921:d332 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.2.99-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Phil Oester commit b396966c4688522863572927cb30aa874b3ec504 upstream. Similar to commit bc6bcb59 ("netfilter: xt_TCPOPTSTRIP: fix possible mangling beyond packet boundary"), add safe fragment handling to xt_TCPMSS. Signed-off-by: Phil Oester Signed-off-by: Pablo Neira Ayuso [bwh: Backported to 3.2: Change parameters for tcpmss_mangle_packet() as done upstream in commit 70d19f805f8c "netfilter: xt_TCPMSS: Fix IPv6 default MSS too"] Signed-off-by: Ben Hutchings --- --- a/net/netfilter/xt_TCPMSS.c +++ b/net/netfilter/xt_TCPMSS.c @@ -44,17 +44,22 @@ optlen(const u_int8_t *opt, unsigned int static int tcpmss_mangle_packet(struct sk_buff *skb, - const struct xt_tcpmss_info *info, + const struct xt_action_param *par, unsigned int in_mtu, unsigned int tcphoff, unsigned int minlen) { + const struct xt_tcpmss_info *info = par->targinfo; struct tcphdr *tcph; unsigned int tcplen, i; __be16 oldval; u16 newmss; u8 *opt; + /* This is a fragment, no TCP header is available */ + if (par->fragoff != 0) + return XT_CONTINUE; + if (!skb_make_writable(skb, skb->len)) return -1; @@ -183,7 +188,7 @@ tcpmss_tg4(struct sk_buff *skb, const st __be16 newlen; int ret; - ret = tcpmss_mangle_packet(skb, par->targinfo, + ret = tcpmss_mangle_packet(skb, par, tcpmss_reverse_mtu(skb, PF_INET), iph->ihl * 4, sizeof(*iph) + sizeof(struct tcphdr)); @@ -211,7 +216,7 @@ tcpmss_tg6(struct sk_buff *skb, const st tcphoff = ipv6_skip_exthdr(skb, sizeof(*ipv6h), &nexthdr); if (tcphoff < 0) return NF_DROP; - ret = tcpmss_mangle_packet(skb, par->targinfo, + ret = tcpmss_mangle_packet(skb, par, tcpmss_reverse_mtu(skb, PF_INET6), tcphoff, sizeof(*ipv6h) + sizeof(struct tcphdr));