Received: by 10.223.185.116 with SMTP id b49csp825553wrg; Sat, 10 Feb 2018 21:17:54 -0800 (PST) X-Google-Smtp-Source: AH8x226JW8JMRJ4xwhsuE74xAuLvFM2oLr8DpGSkCmYPjUq9DvJEvuAxO/XEyzIBTvrS3fhNYa00 X-Received: by 10.98.7.214 with SMTP id 83mr7684672pfh.130.1518326274450; Sat, 10 Feb 2018 21:17:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518326274; cv=none; d=google.com; s=arc-20160816; b=X8YR7cN8M8zvBpxUgaIUtuP05HurHQG8bMlKXcRcWNRFHbsmscaiyYNQ8aErtFvPIo Q04KNZCScs3vsYa1Pox6ulNXfYMZMhUIsx9KbnxIBSjjngzMyyalsZ8RicGnXyGoe1kk Bb+t5jIM51U8T6WBSRwTIUgF9tj89JMGgx49wpOLQ4Khwa9WqtyUNNYb/jHpQl5IXCMr zoJ6GbI9mSvucqzWDfkFb+CXcpmiPh5Pp2DVuPsuGDSrVPBxAGLjOoHyzsFhTbXWJeT+ KQhVVgmAHhg297dQAPGJ6y1UXl4QR+FsBABv5KzRo33IMf/6RmoNq+YXCDq4AKVWgvj0 qGHA== 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=IcfEo9A+Id0ao3yyOT5gOjg6V3t4L0f/5S2SmOyIgOQ=; b=rhCrGXvsEVIIQ+DuleyNi3m78iZ8k2Y9RORSt/ToZZO/TE2sKETNfOwQPZelyAsL83 K9/E1u9mMJI/T17itRhW5IMCUrRY0eBf2PsQfRGyhs3e97B5YOWqyLA5IjMRIoBaCVuB MHBdIOnDXXU/jSBU01I7aIHhCtru9Gh+gMzMwSy+tO50vtizXPyHMP2mkxmilIX1YZQW 0l5xIsfYYG5vmEZanbVe4RjDlm3WNQoTSJlIzMqLaRDLKNq0A+wWBAIKn8rZa+lsH6Jn KZs9XtHC6LHuGfR7kZ5l/vXCPuhsjwOZbH7Ms4SeHBtGsKtnhMByRoe3c/1NY4wNlF7J n0fg== 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 r5-v6si3997653plo.443.2018.02.10.21.17.40; Sat, 10 Feb 2018 21:17:54 -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 S1754047AbeBKFOX (ORCPT + 99 others); Sun, 11 Feb 2018 00:14:23 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:41384 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752616AbeBKEdl (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-0002h9-KJ; Sun, 11 Feb 2018 04:33:39 +0000 Received: from ben by deadeye with local (Exim 4.90) (envelope-from ) id 1ekjKY-0004WQ-LJ; 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, "Phil Oester" , "Pablo Neira Ayuso" , "Florian Westphal" Date: Sun, 11 Feb 2018 04:20:06 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.2 62/79] netfilter: xt_TCPOPTSTRIP: don't use tcp_hdr() 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: Pablo Neira Ayuso commit ed82c437320c48a4032492f4a55a7e2c934158b6 upstream. In (bc6bcb5 netfilter: xt_TCPOPTSTRIP: fix possible mangling beyond packet boundary), the use of tcp_hdr was introduced. However, we cannot assume that skb->transport_header is set for non-local packets. Cc: Florian Westphal Reported-by: Phil Oester Signed-off-by: Pablo Neira Ayuso Signed-off-by: Ben Hutchings --- net/netfilter/xt_TCPOPTSTRIP.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/net/netfilter/xt_TCPOPTSTRIP.c +++ b/net/netfilter/xt_TCPOPTSTRIP.c @@ -48,11 +48,13 @@ tcpoptstrip_mangle_packet(struct sk_buff return NF_DROP; len = skb->len - tcphoff; - if (len < (int)sizeof(struct tcphdr) || - tcp_hdr(skb)->doff * 4 > len) + if (len < (int)sizeof(struct tcphdr)) return NF_DROP; tcph = (struct tcphdr *)(skb_network_header(skb) + tcphoff); + if (tcph->doff * 4 > len) + return NF_DROP; + opt = (u_int8_t *)tcph; /*