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.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 1B279C388F7 for ; Thu, 22 Oct 2020 14:23:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B60A424182 for ; Thu, 22 Oct 2020 14:23:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mg.codeaurora.org header.i=@mg.codeaurora.org header.b="vKTg0ugx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S368125AbgJVOXf (ORCPT ); Thu, 22 Oct 2020 10:23:35 -0400 Received: from m42-4.mailgun.net ([69.72.42.4]:42283 "EHLO m42-4.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S368111AbgJVOXf (ORCPT ); Thu, 22 Oct 2020 10:23:35 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1603376614; h=Message-ID: References: In-Reply-To: Subject: Cc: To: From: Date: Content-Transfer-Encoding: Content-Type: MIME-Version: Sender; bh=5qB5Dccn15buC2KJI/Udo57VxjYkbuR0df0+slTqVyE=; b=vKTg0ugxv9zJwsfyyOcKLIdR5c1zM8vLqm85vChV7UMDHL7BMjYA+TD7z32jo/pMZCrReTzU jMklwdcJknIQS3LQvvdRFWlmJXH+GJ7cxyset/zdC9kP9A2nq0/k+IGVQ2EiId1T+a48TPJu wbR+AyRbJym6SCDVzxfoLP+IO9k= X-Mailgun-Sending-Ip: 69.72.42.4 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n02.prod.us-east-1.postgun.com with SMTP id 5f9195e53711fec7b136efd5 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Thu, 22 Oct 2020 14:23:33 GMT Sender: saiprakash.ranjan=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 2C0ABC43395; Thu, 22 Oct 2020 14:23:33 +0000 (UTC) Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: saiprakash.ranjan) by smtp.codeaurora.org (Postfix) with ESMTPSA id 40BC8C433CB; Thu, 22 Oct 2020 14:23:32 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Thu, 22 Oct 2020 19:53:32 +0530 From: Sai Prakash Ranjan To: Peter Zijlstra Cc: Mark Rutland , Mathieu Poirier , Suzuki K Poulose , Alexander Shishkin , linux-arm-msm@vger.kernel.org, coresight@lists.linaro.org, linux-kernel@vger.kernel.org, Arnaldo Carvalho de Melo , Stephen Boyd , Ingo Molnar , Namhyung Kim , Jiri Olsa , linux-arm-kernel@lists.infradead.org, Mike Leach Subject: Re: [PATCHv2 2/4] coresight: tmc-etf: Fix NULL ptr dereference in tmc_enable_etf_sink_perf() In-Reply-To: <20201022133414.GH2611@hirez.programming.kicks-ass.net> References: <20201022113214.GD2611@hirez.programming.kicks-ass.net> <20201022133414.GH2611@hirez.programming.kicks-ass.net> Message-ID: <8ecb29f116a78855ca59928c1e0e1eb7@codeaurora.org> X-Sender: saiprakash.ranjan@codeaurora.org User-Agent: Roundcube Webmail/1.3.9 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-10-22 19:04, Peter Zijlstra wrote: > On Thu, Oct 22, 2020 at 06:19:37PM +0530, Sai Prakash Ranjan wrote: >> On 2020-10-22 17:02, 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? >> > >> >> The original issue was the owner being NULL and causing >> a NULL pointer dereference. I did ask some time back >> if it is valid for the owner to be NULL [1] and should >> probably be handled in events core? > > No, what I asked is why do you care about ->owner to begin with? That > seems wrong. A driver should not touch ->owner _at_all_. > Ah ok, so Suzuki explained that in other reply and if there is some other better way? Thanks, Sai -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation