Received: by 10.213.65.68 with SMTP id h4csp422604imn; Tue, 13 Mar 2018 08:34:37 -0700 (PDT) X-Google-Smtp-Source: AG47ELvC+aZZ5WVFbNSgzlK+QUmJH0gm/Va3hcaggmM4dBr18aevcPGbKLnVehQkjzc9R5KdlYIN X-Received: by 10.98.131.4 with SMTP id h4mr1031335pfe.156.1520955277565; Tue, 13 Mar 2018 08:34:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520955277; cv=none; d=google.com; s=arc-20160816; b=NgxyNEQwun3BHhAL+pibU3GIcPk8kQ2Xcbdhl1VLWwrpQTNQ+0gqY/rwNTQeGwIgy+ HL8D9bzrWUJRETVuLJrIgMX3Azl6/Kbz1UaOYnyL25Pjl7Wj6JVm/6Y+d3MpjUoK5d9p aNUX+hh5tDno6qBLfgwc9EvjMZmigV3mbXvhuNfc77L5MX50Zl32Ey+RI9tG19TfkFit b+aVEAzyKZFY1avgzuXDQoQscE2BiYO4O0GWGUahodTid/k7KpdFSJ70upRcvShVMgAt aywghWVtepySetY/XV05BMZfdkrFnlGYWAHqC3S7xDLKJj2+Lp4L+cgKqb3dyfEXeRoA 9sRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=S2XJiGkkXOqirTvmYY92cCUJ5kdBB2Cu5a45EDEaQ0s=; b=VfXpsVlBm2MW8OR5c1sC4oLBTxuTp7uH83qePRlg5y26gDEj9MQ2NWM4jn8H0uc/Ox qDO63GhIlQBnBY8E+b9rT+aJSu/x6ZQ+HUNlZ/2rvGkM/sgcDu2Tm4EqAHL83yfQ7M9e NJMOHrSKPbMohH6GWzr7VsxC6C3O6S9WTencfv0+Z+sYNiuv7R2+ZhYO/c+m1Ml7X1+h Eh8NLaMdCYDNR/kyPDga+47BbnDCPRLKJrYg2Ocsi2nzXM9kJNMYXZC8I8vVA8SmVeEl CTKQaj4++S5srxNgmUSJb3+TDGMEFBSigR1nsFJ7dWLsGHjSHdRF3m6V7lNarnHpfAOC R4bg== 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 f10-v6si294334plm.188.2018.03.13.08.34.23; Tue, 13 Mar 2018 08:34:37 -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 S933486AbeCMPdD (ORCPT + 99 others); Tue, 13 Mar 2018 11:33:03 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:59944 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933469AbeCMPc7 (ORCPT ); Tue, 13 Mar 2018 11:32:59 -0400 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 617E81221; Tue, 13 Mar 2018 15:32:58 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Florian Westphal , Pablo Neira Ayuso Subject: [PATCH 4.15 116/146] netfilter: ipv6: fix use-after-free Write in nf_nat_ipv6_manip_pkt Date: Tue, 13 Mar 2018 16:24:43 +0100 Message-Id: <20180313152329.316873638@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180313152320.439085687@linuxfoundation.org> References: <20180313152320.439085687@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Florian Westphal commit b078556aecd791b0e5cb3a59f4c3a14273b52121 upstream. l4proto->manip_pkt() can cause reallocation of skb head so pointer to the ipv6 header must be reloaded. Reported-and-tested-by: Fixes: 58a317f1061c89 ("netfilter: ipv6: add IPv6 NAT support") Signed-off-by: Florian Westphal Signed-off-by: Pablo Neira Ayuso Signed-off-by: Greg Kroah-Hartman --- net/ipv6/netfilter/nf_nat_l3proto_ipv6.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/net/ipv6/netfilter/nf_nat_l3proto_ipv6.c +++ b/net/ipv6/netfilter/nf_nat_l3proto_ipv6.c @@ -99,6 +99,10 @@ static bool nf_nat_ipv6_manip_pkt(struct !l4proto->manip_pkt(skb, &nf_nat_l3proto_ipv6, iphdroff, hdroff, target, maniptype)) return false; + + /* must reload, offset might have changed */ + ipv6h = (void *)skb->data + iphdroff; + manip_addr: if (maniptype == NF_NAT_MANIP_SRC) ipv6h->saddr = target->src.u3.in6;