Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2988707imu; Sun, 9 Dec 2018 14:24:45 -0800 (PST) X-Google-Smtp-Source: AFSGD/VeSdDjOAYQTY6n6n/pEwhCZ44gUrGbWZqSssP+tF7aMywWFLSeJMPQcPvG894J58JzjG6B X-Received: by 2002:a17:902:3281:: with SMTP id z1mr10076302plb.296.1544394285176; Sun, 09 Dec 2018 14:24:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544394285; cv=none; d=google.com; s=arc-20160816; b=dzDCN8yBAmFKT4OfeYlJaiIpaW/ytJpqH2agHd+MqaGAPJMx3gugl/3Ul1f2LDK6ld q6rd9ag76FPiHvBrktm08cgScj5ixTVsiz81SEs/G2XqGKZ8uZSc/KGOu4tas2MRbFdu TN81GI5SPjEjcyvdShS/RcQ8yIjNHV5aPfnQLu08c63FGQILkcfO5QC93hIjgQFtCmf9 AbAbtWC1+F4A6mEztRk0nDD5wQKVksVnEYiSvk4ChrCes5UVUbpmVPXCZOwmm3JogXqg +zUYRMnbiuBeYs6b9V6BYAnzHCMZ4WuVzAHo/ww5WqYeNZodtKuViWJG/guYIbuhuwGH n6/Q== 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; bh=sr6SP6r5k8oMxZr3QXStrYu2vYM+kz8uOj+kqv0OZ0k=; b=lukgvDLabeSHHev+TsaSt5fJLc6NXqX5kTby+Dm0JEHVlY1abSOz5F3n1976+BDPqw PEf/1M7N+CYyRfWZucy2HkPo4b8BF2uMNRAGk6WeTTB4q4V1DZGT5rdelAuTwDbsOxcd h3TTQIGjf8bhpVZw7pbbuYbc1c6q5SI27sclGv/B+dsv2muYQjx2b76921avjTLxpWJk 6UlE2OoAnrnplsC1JZc8VPMVoi8DvT6sGD8mkPqgde8Q4KdI4XqnwQHTQfy7MYTfTOEs 4zKnJTBkvkhZTOv6BzTQPN1Joke8LZYnPxpyRzyV7TzvMZXL+6s56jGZSy++6/GqvpI7 ss4A== 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 bb4si8263261plb.322.2018.12.09.14.24.30; Sun, 09 Dec 2018 14:24:45 -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 S1726690AbeLIWWJ (ORCPT + 99 others); Sun, 9 Dec 2018 17:22:09 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:35192 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726515AbeLIVzV (ORCPT ); Sun, 9 Dec 2018 16:55:21 -0500 Received: from pub.yeoldevic.com ([81.174.156.145] helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gW72k-0002po-OX; Sun, 09 Dec 2018 21:55:18 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gW72i-0003Zq-62; Sun, 09 Dec 2018 21:55:16 +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, "Eric Dumazet" , "David S. Miller" , "syzbot" Date: Sun, 09 Dec 2018 21:50:33 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 243/328] ipv6: fix possible use-after-free in ip6_xmit() In-Reply-To: X-SA-Exim-Connect-IP: 81.174.156.145 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.16.62-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Eric Dumazet commit bbd6528d28c1b8e80832b3b018ec402b6f5c3215 upstream. 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 [bwh: Backported to 3.16: adjust context] Signed-off-by: Ben Hutchings --- --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c @@ -183,9 +183,10 @@ int ip6_xmit(struct sock *sk, struct sk_ kfree_skb(skb); return -ENOBUFS; } + if (skb->sk) + skb_set_owner_w(skb2, skb->sk); consume_skb(skb); skb = skb2; - skb_set_owner_w(skb, sk); } if (opt->opt_flen) ipv6_push_frag_opts(skb, opt, &proto);