From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932974AbdCGRaZ (ORCPT ); Tue, 7 Mar 2017 12:30:25 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:54053 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932941AbdCGRaM (ORCPT ); Tue, 7 Mar 2017 12:30:12 -0500 Date: Tue, 7 Mar 2017 18:29:58 +0100 From: Peter Zijlstra To: Oleg Nesterov Cc: Dmitry Vyukov , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , LKML , Mathieu Desnoyers , syzkaller Subject: Re: perf: use-after-free in perf_release Message-ID: <20170307172958.GB3312@twins.programming.kicks-ass.net> References: <20170306131459.GC6515@twins.programming.kicks-ass.net> <20170307140414.GA31678@redhat.com> <20170307165131.GA6097@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170307165131.GA6097@redhat.com> User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 07, 2017 at 05:51:32PM +0100, Oleg Nesterov wrote: > On 03/07, Dmitry Vyukov wrote: > > I would what is that that is failed in copy_process. Could it be > > perf_event_init_task itself? Maybe it leaves a pointer to p in some > > shared state on some error conditions? > > I am looking at perf_event_init_task() too and I can't understand the > error handling... > > perf_event_init_context() can return success even if inherit_task_group() in > the first list_for_each_entry(pinned_groups) fails, "ret" will be overwritten > by the 2nd list_for_each_entry(flexible_groups) loop. "inherited_all" should > be cleared, still this looks confusing at least. > > inherit_event() returns NULL under is_orphaned_event() check, not ERR_PTR(). > Is it correct? Urgh, there was something tricky there, but I cannot remember, and it seems we didn't put a comment in either :/ Alexander, can you remember? But yes, this all looks a tad dodgy, I'll try and have a look, but I feel like I'm coming down with something :-(