Received: by 10.213.65.68 with SMTP id h4csp444704imn; Tue, 13 Mar 2018 09:15:00 -0700 (PDT) X-Google-Smtp-Source: AG47ELtL0QhpY6GJiJ1cRmWqT8z7JT1G6cHMNvZg3J+C3UuawAtTj9RbBsntsE31ei8odvxhKN48 X-Received: by 2002:a17:902:8349:: with SMTP id z9-v6mr1045263pln.163.1520957700547; Tue, 13 Mar 2018 09:15:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520957700; cv=none; d=google.com; s=arc-20160816; b=CyE+c7RLSffYEEVSiZBKFzOSitmeg1a92xtpqTwqZBsNdwCz7z5826QMxV6tPBm3Q7 tpiIatW6iSzaNNvQJ3c4FyeWzD3bRVP9OBQ8OcRECf3LU1XZEQpnpSksgQfOk0BHGu3c aoCbDm+aIda7yX1Yqn9lYicnmgAG+61YuDxD5JgrLiWkNRoFb/uyieUom4UAVJXft2Zb g+gjquoEpUPUAQkkDWcS+59T3sCM8EZ0jzf/U+0eiC+OVR+bSNYOivpZLjXvfOHqhXtP r79EvAcPE+6weQAAtWnL0TB0231oYyzBo3aBYX4ptTxwd0jgABm7wXdxJs7LGTlq2vFs +sng== 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=prqEHuvt5fhh+6KuRgcbg4JbKm0yVYSMJ5TNckrW7DM=; b=cOkHcqm5M3bJrU/V+P2g5L2/tTHTmbM6+GTx+hFb4jzrK6r0KsWsUaHx51Pp5KgAEm sG+4KiWarChJ6A7fHBxlwIb4NCNdJk8773dFpGupsyEHIL0yRO8z3jNF2YQvAsgHmbFc d2Rn6zvheMzdchrNqPCGlp17kFRUyhch7eXQ1BpVKZ9nJMzdy/qxqI0h8NQAf+x5qQaU 1GcA9spi/d3IjCccoMbRq1JzVwTrL81yfvwPKDr5kOf92AbXtY4teLkc2iKiXPlt+Wtu vUQMYuEGWJzwfNTmJurEOfEN7IIKq5NQJOAeXga6kVeYvrNgIT5fTdjWIMyff8k+lOQS PThw== 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 e30si262441pgn.261.2018.03.13.09.14.45; Tue, 13 Mar 2018 09:15:00 -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 S934073AbeCMPfq (ORCPT + 99 others); Tue, 13 Mar 2018 11:35:46 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:33248 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933991AbeCMPfm (ORCPT ); Tue, 13 Mar 2018 11:35:42 -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 3CF371164; Tue, 13 Mar 2018 15:35:41 +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.14 017/140] netfilter: ipv6: fix use-after-free Write in nf_nat_ipv6_manip_pkt Date: Tue, 13 Mar 2018 16:23:40 +0100 Message-Id: <20180313152459.265210480@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180313152458.201155692@linuxfoundation.org> References: <20180313152458.201155692@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.14-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;