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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 21E94C433E7 for ; Wed, 14 Oct 2020 09:38:07 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 953382076D for ; Wed, 14 Oct 2020 09:38:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="BW/4W6Rt"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mg.codeaurora.org header.i=@mg.codeaurora.org header.b="m0YNRrMz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 953382076D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Type: Content-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Message-ID:References:In-Reply-To:Subject:To:From: Date:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=lLeaaqAevllrpL9Jflte4tzRZPRtw0AHCvohBndwbvY=; b=BW/4W6RtD1AO/kfok5aYQAvqD xwfVv4KkzjBx3+UigqwDlOw5nm0y+gRA0Eai2eiXHki+9+iB62JNqkt4t1r0CutNvmJio38V72hVk T0RqK2PEkAXLr65fQO47e5928zgyH9H1T5AC3HC5oZlp5zyQBpdNUrhC5GRqm/GecF7u40awiIFl1 nf4qAQExiJyNfB8jauk89b8Bq8kiEG3liSTB+U269tFwaSGmLudSjwAMpWZKyxzwvmHg8d1glke/o 8XvmkBBNh48ypyDXw/0JEp9tMMiM6RlQKX3lYV9gmB3XVstMi6wP0gIMdwb1P5dKDakupwOJjq4eB agbAplVkw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kSdDF-0007lQ-Sk; Wed, 14 Oct 2020 09:36:49 +0000 Received: from m42-4.mailgun.net ([69.72.42.4]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kSdD4-0007iw-SO for linux-arm-kernel@lists.infradead.org; Wed, 14 Oct 2020 09:36:47 +0000 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1602668206; h=Message-ID: References: In-Reply-To: Subject: Cc: To: From: Date: Content-Transfer-Encoding: Content-Type: MIME-Version: Sender; bh=FTOEQCtqGMGUz2rk9/7VbauWsNvXRMhYgIKm7qBcvx8=; b=m0YNRrMzURn+ehv7JEFtOw5T48QbFpEWwOYOEc5hJ4SUd2o5ZB/3xLYekgit9oBtfiRGhqvS PjbQzx+P9fMlcWx2G0j7nIZDPsyoUVVD88Pli2e+1CoD79vf5VW1/+ENN3DdM4SzUfMRNBPi zbRdjcKvaAWCmvl+0yYzwsrAy8o= X-Mailgun-Sending-Ip: 69.72.42.4 X-Mailgun-Sid: WyJiYzAxZiIsICJsaW51eC1hcm0ta2VybmVsQGxpc3RzLmluZnJhZGVhZC5vcmciLCAiYmU5ZTRhIl0= 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-west-2.postgun.com with SMTP id 5f86c69d06d81bc48df2ba9e (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Wed, 14 Oct 2020 09:36:29 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id C614EC43391; Wed, 14 Oct 2020 09:36:29 +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 03487C433F1; Wed, 14 Oct 2020 09:36:28 +0000 (UTC) MIME-Version: 1.0 Date: Wed, 14 Oct 2020 15:06:28 +0530 From: Sai Prakash Ranjan To: Suzuki K Poulose Subject: Re: [PATCH 1/2] coresight: tmc-etf: Fix NULL ptr dereference in tmc_enable_etf_sink_perf() In-Reply-To: <5bbb2d35-3e56-56d7-4722-bf34c5efa2fb@arm.com> References: <5bbb2d35-3e56-56d7-4722-bf34c5efa2fb@arm.com> Message-ID: <9fa4fcc25dac17b343d151a9d089b48c@codeaurora.org> X-Sender: saiprakash.ranjan@codeaurora.org User-Agent: Roundcube Webmail/1.3.9 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201014_053646_240396_55249FBB X-CRM114-Status: GOOD ( 18.21 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mathieu.poirier@linaro.org, peterz@infradead.org, linux-arm-msm@vger.kernel.org, coresight@lists.linaro.org, linux-kernel@vger.kernel.org, swboyd@chromium.org, denik@google.com, leo.yan@linaro.org, linux-arm-kernel@lists.infradead.org, mike.leach@linaro.org Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 2020-10-13 22:05, Suzuki K Poulose wrote: > On 10/07/2020 02:00 PM, Sai Prakash Ranjan wrote: >> There was a report of NULL pointer dereference in ETF enable >> path for perf CS mode with PID monitoring. It is almost 100% >> reproducible when the process to monitor is something very >> active such as chrome and with ETF as the sink and not ETR. >> Currently in a bid to find the pid, the owner is dereferenced >> via task_pid_nr() call in tmc_enable_etf_sink_perf() and with >> owner being NULL, we get a NULL pointer dereference. >> >> 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. Owner(task) is NULL even >> in the case of ETR in tmc_enable_etr_sink_perf(), but since we >> cache the PID in alloc_buffer() callback and it is done as part >> of etm_setup_aux() when allocating buffer for ETR sink, we never >> dereference this NULL pointer and we are safe. So lets do the > > The patch is necessary to fix some of the issues. But I feel it is > not complete. Why is it safe earlier and not later ? I believe we are > simply reducing the chances of hitting the issue, by doing this earlier > than > later. I would say we better fix all instances to make sure that the > event->owner is valid. (e.g, I can see that the for kernel events > event->owner == -1 ?) > > struct task_struct *tsk = READ_ONCE(event->owner); > > if (!tsk || is_kernel_event(event)) > /* skip ? */ > Looking at it some more, is_kernel_event() is not exposed outside events core and probably for good reason. Why do we need to check for this and not just tsk? Thanks, Sai -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel