Received: by 10.213.65.68 with SMTP id h4csp514978imn; Fri, 16 Mar 2018 10:05:29 -0700 (PDT) X-Google-Smtp-Source: AG47ELu3tapFZjJvrg8K3hTPL0AJ4BNlaGnKWZSzrJXEVwbXBptZR76pg31FJuLoOaWBj/5+jdED X-Received: by 2002:a17:902:6684:: with SMTP id e4-v6mr2950476plk.373.1521219929734; Fri, 16 Mar 2018 10:05:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521219929; cv=none; d=google.com; s=arc-20160816; b=v9N/BD5V0rCk1qxGvbKj60DZLjrXun8V8oUnhjfQjX+2VDRITKUj9tBGmQDGDo887c /tqlh+2vUgRga8KppwS5OmjLPiNul1Y2gExTUYz9LbUVS+T9ShrS9yCoxvdHadqRUn6m cDUrGpCHFhp6evJI2Rz9KEMvxxv0wUCOV0w1lFAGr/Hd0VhRN75omiF8W2vadTlmdc7V hrrE/gleOwPDY+nYmRlN/TA9honSJDzpvitWxuEDGgfVaB90xu5fq0ptppKklU3yug+3 6Uh4TWii/gHqCXnI4k+FnC1M2MZtzF1Jf8ow02r5sNBlFYwZBUFAfXLl0ZnaMi5Oe4TT vEpQ== 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=7ouNjhqoCzSXQArjlUPp4t52NNJU82baUjdc1rBNHKo=; b=kc5b9nP85/mGkZXe/UD0No988yEiboLmdTL8hnrdB8DmnhL+1gFu2p+RZs1T8jnfwJ QjNHQbx3HuwCAYr6JgCfWBAVJm04UJtsFZku2YgUJMuo+KRXQrEMhGv1XMs6xfLE823H D+ovx/Gha3CrbHxWTVDsmouM1rVI9L1y8SHyY6hHhZ8Fw2dhDU4Cza0AenLgwbwLaYg3 9zuCHWfnZ1BLdgjCHCnTFqvs9M4qFTSipEJuBuvLkQ5HgnOO6VuT9LjKhdVeC+i5GRDb OAW39JKffU067Lo/ke6gxVsZ+Xce1FTXGemuHKxTNlVdkdC+iuAVXy4ebdOssRKXdznd kGAw== 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 ba10-v6si6422498plb.5.2018.03.16.10.05.15; Fri, 16 Mar 2018 10:05:29 -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 S932891AbeCPRDQ (ORCPT + 99 others); Fri, 16 Mar 2018 13:03:16 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:37902 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933518AbeCPPcU (ORCPT ); Fri, 16 Mar 2018 11:32:20 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 9854311BF; Fri, 16 Mar 2018 15:32:19 +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.9 60/86] netfilter: ipv6: fix use-after-free Write in nf_nat_ipv6_manip_pkt Date: Fri, 16 Mar 2018 16:23:23 +0100 Message-Id: <20180316152321.434548741@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180316152317.167709497@linuxfoundation.org> References: <20180316152317.167709497@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.9-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;