From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5A3B7C55179 for ; Thu, 22 Oct 2020 15:06:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E25BC24630 for ; Thu, 22 Oct 2020 15:06:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="SbTY4rX1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2901104AbgJVPGX (ORCPT ); Thu, 22 Oct 2020 11:06:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2901103AbgJVPGX (ORCPT ); Thu, 22 Oct 2020 11:06:23 -0400 Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A593CC0613CE; Thu, 22 Oct 2020 08:06:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=qOlWPg0bC1NWd34FmUCHzoVruWTwluBkXAwb9GIDaWs=; b=SbTY4rX1WvslbubYBPa9ihCpd/ qtCx5W8pkT2O6U1dDXpb3yA6FKGPjNvZAq7Avs8cpVrDlt7cfSPIiAz3EMr2lCU4UWCAMPsPt4Fx2 0F0V2V830Fykt3zjSzDt2TcmRB4F2Opsy9tf/aw8AcpKhKH206VrrOKBARdBmUy60zuMuDuoPpJIa Vm/vNDob23cO+CP29rrwRFcuwrUshhq4XgwSJapNsfaGHKTHj+yrBs80JBTyjHDezaeC7XDe9RSv9 vmMPJgIiY7mC3SbE6ad2TPYnRmBDbYlLc3lQ24YWGYk5K36Srm81bDkKPotH23IKMA7ndda3zZ2wj Guz1aPZw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kVcAP-0004Kr-Bo; Thu, 22 Oct 2020 15:06:13 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id A4C0D3011C6; Thu, 22 Oct 2020 17:06:09 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 725A9203D0827; Thu, 22 Oct 2020 17:06:09 +0200 (CEST) Date: Thu, 22 Oct 2020 17:06:09 +0200 From: Peter Zijlstra To: Suzuki Poulose Cc: Sai Prakash Ranjan , Mathieu Poirier , Mike Leach , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , coresight@lists.linaro.org, Stephen Boyd , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCHv2 2/4] coresight: tmc-etf: Fix NULL ptr dereference in tmc_enable_etf_sink_perf() Message-ID: <20201022150609.GI2611@hirez.programming.kicks-ass.net> References: <20201022113214.GD2611@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org On Thu, Oct 22, 2020 at 02:30:21PM +0100, Suzuki Poulose wrote: > On 10/22/20 12:32 PM, Peter Zijlstra wrote: > > On Thu, Oct 22, 2020 at 04:27:52PM +0530, Sai Prakash Ranjan wrote: > > > > > Looking at the ETR and other places in the kernel, ETF and the > > > ETB are the only places trying to dereference the task(owner) > > > in tmc_enable_etf_sink_perf() which is also called from the > > > sched_in path as in the call trace. > > > > > @@ -391,6 +392,10 @@ static void *tmc_alloc_etf_buffer(struct coresight_device *csdev, > > > { > > > int node; > > > struct cs_buffers *buf; > > > + struct task_struct *task = READ_ONCE(event->owner); > > > + > > > + if (!task || is_kernel_event(event)) > > > + return NULL; > > > > > > This is *wrong*... why do you care about who owns the events? > > > > This is due to the special case of the CoreSight configuration, where > a "sink" (where the trace data is captured) is shared by multiple Trace > units. So, we could share the "sink" for multiple trace units if they > are tracing the events that belong to the same "perf" session. (The > userspace tool could decode the trace data based on the TraceID > in the trace packets). Is there a better way to do this ? I thought we added sink identification through perf_event_attr::config2 ?