Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1778519imm; Thu, 27 Sep 2018 02:18:56 -0700 (PDT) X-Google-Smtp-Source: ACcGV61vOSHqUZ/NWOnkZapftbJwEev+YH3UxvRzsyAuiyhiDsqengwtRig+qFTTwX/vIU4idBBn X-Received: by 2002:a63:e505:: with SMTP id r5-v6mr9375363pgh.170.1538039936671; Thu, 27 Sep 2018 02:18:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538039936; cv=none; d=google.com; s=arc-20160816; b=HP/OMLls0txEcPFXUilOdVyhdGW6kngLCvF07yydPLVQ18Ds0ADUOakZ2KuaaaPCiJ //Q5Gk8Y5aatwETUi8aqGQGxEOrx/v4jvdyZHoZIGyBfk1tvzgDUS8rRv6HqANh/XgLy TyMSiVU+1vC4UWyRu02lpApyTpTAf/fzxDCf8KJDqTHvfXkSN7z0H6eNQiGa3B45sTTr CMjxM16hR436T9NPNtcKeG37XmMqKOXctr4N6mHRvHAThC69TL0XbnOj2vssmXAmSAYy b3koTa9PNd8nuMH2Rq8V/mPOrWjOtH25xtHBoimDs26wOSd79rDIM2ZLCG2u8rXmAuIp tcvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=esdatZSuoVAmUWgyx6lg/yXetOzajZAoAS9WWTO/NMk=; b=f7Y6R89Gyf138p/ENzGycSBMkKMPeWm9qB4hTLznQWunL4ma0nadx2OEiXa9UOYbuS DlTAUR9JS+R3CZkh3XyAcS6HsvD2ujsChJ6CM7a3oeN7HJWscVcqlS2h4oL9L5lLSIXi FLgx7/ADBiLkVSY0ZCKGM81GvPFAIP758037j7STgP5ea/hppyWKhLubBiQgW7KmOZnm XNnZGSs3gdcw7XB/Iwbzu7u4e0hPzK0cQuiX7HKsclWQLvaQjCmtOJ0VVzRl0yL0BQzV KVvpumhwbhqZ0NzQtQj+UglUX0fd6ZOB+vK6DyuWgErdEEwIpczJ4zCyHSmX8X5pHXqv BBhQ== 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 b137-v6si1517562pga.90.2018.09.27.02.18.41; Thu, 27 Sep 2018 02:18:56 -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 S1728899AbeI0Pe6 (ORCPT + 99 others); Thu, 27 Sep 2018 11:34:58 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:56068 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727272AbeI0Pe5 (ORCPT ); Thu, 27 Sep 2018 11:34:57 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id A53B3110D; Thu, 27 Sep 2018 09:17:39 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , syzbot , "David S. Miller" Subject: [PATCH 4.14 02/64] ipv6: fix possible use-after-free in ip6_xmit() Date: Thu, 27 Sep 2018 11:03:19 +0200 Message-Id: <20180927090250.130790874@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180927090249.801943776@linuxfoundation.org> References: <20180927090249.801943776@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: Eric Dumazet [ Upstream commit bbd6528d28c1b8e80832b3b018ec402b6f5c3215 ] In the unlikely case ip6_xmit() has to call skb_realloc_headroom(), we need to call skb_set_owner_w() before consuming original skb, otherwise we risk a use-after-free. Bring IPv6 in line with what we do in IPv4 to fix this. Fixes: 1da177e4c3f41 ("Linux-2.6.12-rc2") Signed-off-by: Eric Dumazet Reported-by: syzbot Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv6/ip6_output.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c @@ -219,12 +219,10 @@ int ip6_xmit(const struct sock *sk, stru kfree_skb(skb); return -ENOBUFS; } + if (skb->sk) + skb_set_owner_w(skb2, skb->sk); consume_skb(skb); skb = skb2; - /* skb_set_owner_w() changes sk->sk_wmem_alloc atomically, - * it is safe to call in our context (socket lock not held) - */ - skb_set_owner_w(skb, (struct sock *)sk); } if (opt->opt_flen) ipv6_push_frag_opts(skb, opt, &proto);