From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967073AbcAZRYc (ORCPT ); Tue, 26 Jan 2016 12:24:32 -0500 Received: from casper.infradead.org ([85.118.1.10]:35205 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966811AbcAZRYa (ORCPT ); Tue, 26 Jan 2016 12:24:30 -0500 Date: Tue, 26 Jan 2016 18:24:25 +0100 From: Peter Zijlstra To: Alexei Starovoitov Cc: Alexander Shishkin , Ingo Molnar , linux-kernel@vger.kernel.org, vince@deater.net, eranian@google.com, Arnaldo Carvalho de Melo , Jiri Olsa , Daniel Borkmann , Wang Nan Subject: Re: [PATCH v2] perf: Synchronously cleanup child events Message-ID: <20160126172425.GJ6375@twins.programming.kicks-ass.net> References: <1453216354-9282-1-git-send-email-alexander.shishkin@linux.intel.com> <20160119200558.GC6357@twins.programming.kicks-ass.net> <87lh7hhmnn.fsf@ashishki-desk.ger.corp.intel.com> <20160122123847.GS6357@twins.programming.kicks-ass.net> <20160122194403.GC11338@ast-mbp.thefacebook.com> <20160125114846.GW6357@twins.programming.kicks-ass.net> <20160125145414.GG6375@twins.programming.kicks-ass.net> <20160125210410.GH6375@twins.programming.kicks-ass.net> <20160126045947.GA40151@ast-mbp.thefacebook.com> <20160126161637.GF6357@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160126161637.GF6357@twins.programming.kicks-ass.net> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 26, 2016 at 05:16:37PM +0100, Peter Zijlstra wrote: > > +struct file *perf_event_get(unsigned int fd) > > { > > + struct file *file; > > > > + file = fget_raw(fd); > > fget_raw() to guarantee the return value isn't NULL? afaict the O_PATH > stuff does not apply to perf events, so you'd put any fd for which the > distinction matters anyway. > > > + if (file->f_op != &perf_fops) { > > + fput(file); > > + return ERR_PTR(-EBADF); > > + } > > > > + return file; > > } It is not possible for one thread to concurrently call close() while this thread tries to fget() ? In which case, we must check the return value anyway?