Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp5878839pxu; Thu, 22 Oct 2020 13:27:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8ny3ZLTAE9Z9fosBhE2X7LQ0NrrnoHmqgzQwC7orNoH2Y4LJvNx+Yeaa9cCiQRFSVYgfd X-Received: by 2002:a17:906:249a:: with SMTP id e26mr3994267ejb.484.1603398468830; Thu, 22 Oct 2020 13:27:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603398468; cv=none; d=google.com; s=arc-20160816; b=mICDsi1bpRyjbKZgvUitC3JH5Z5uuVg5l9f+ddo1IY3PaKq+AkyhutlS1LNcmauyse o0rPXSYEYIzj59jk543QhA0O+ka4x+bo23IgYyTRuCDb4yhIWOevpfasA4HbIlSeXr9P UE9SfpapLcTmesL2ArFPzWdXN7ZhxKxE1qQ1Xu4B4TdVHbGiP6fBekY+/x710mbkbTjY XtHnyJtZMLHW264eDrJaGCY3yj/ZCL6UyMHsuTdJRV1/TQmIPwLNpAsADrphnIWjTnvv tw6p6jTqW40IGFBZl6MUbQxSjiOAvfP8Fw7e9X1Z9Jvgc0u9j8dyFmkAwDOsmPE5lgc3 H72g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=qOlWPg0bC1NWd34FmUCHzoVruWTwluBkXAwb9GIDaWs=; b=D9xfrw2AV7M//sPVXpl/QChdZQu1imn4CBtakG9Xo/urlZgpqq1JaYQy0BKibKGIu7 e0ij5z5jX4+sQ2nQiX9vajg9202cAn/borw2gk0qHh8L5rzWH/EeylXF0tx961MYo/fH zd/0CQunXOgRXF72ne3UWasxg71C3yOrOfyAJbzXhOMKoRGOCDPk1mBXPf1KFeYWYgY9 Lu3YKzq2WPw2qJMtq0QPR1OCAwP6GhN1jd7oowgrCAJZHdGGPNm+30aWC4WjVbIsk7l/ ASdywzyTFQFVr07U2AEWYD5dQ6NYDaQLMH695nI5sfnF9+Qf+H2spXM7qAEO6nDE9ERK rnpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=merlin.20170209 header.b=SbTY4rX1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m4si1632213edv.101.2020.10.22.13.27.27; Thu, 22 Oct 2020 13:27:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=merlin.20170209 header.b=SbTY4rX1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2901107AbgJVPGX (ORCPT + 99 others); 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-kernel@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 ?