Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp5866849pxu; Thu, 22 Oct 2020 13:07:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxyPy0Bz12TkX3hsUkoQyzG1kN9M/wccIHZLwCeahNTWvIqczbOZtfI322kIRB/5YsjfeOJ X-Received: by 2002:aa7:dc16:: with SMTP id b22mr3827265edu.252.1603397265477; Thu, 22 Oct 2020 13:07:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603397265; cv=none; d=google.com; s=arc-20160816; b=aoJGDpaNh3Kgw9o3Kea1sxRXgU0G3mqKmPEVOX60AqjN3pyTdawixpLyDKMHvFhNzm u8CETG/Y12gabg/YeATpO4xwS8OWlM3UMt5zxIPFHyAu8YnixmYfQp0tX31bsjB/CKot tg0wknmWr6V61Ds7ILiIHHv2wU8kE0Se1vqu7Ul1JUZWfwI88h5SQrO6Xwqjavhhan+y WGnRVEuTBtChmi4H7nFT207wmoeFThZ30clVOxpgyyJSOcvPti2VNWIYO/iQ9kKVicwH Y0DLBJ9KcD4BX2hpzzHYm86dvaJcpyIkmY4QAlbHN3NLXkhZa1ooXozMK9SPISHfurTV vYzg== 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=H93ZL99+6WZCe8jHCr+h/wqqN11hUYMAzdxBzDI+Dbw=; b=t+x3+wvz4RTOY+fplkPY8bG+QHt+4l8JhIQ0Wvk8q4N5DwWd0fysXvOYffS6jzl18e HnrLDFgWfHkRmqN6XZ5Xfdvw0pjqxPZ9urocWLiNreSmCN8A0KK0I/xl2QDU6qSugrMu ypbzdtTGCrUqAbn7oVuf0F1w+BA5y0ajZ7gJG/DoAWEQa4bIKwGWcsIFW5+NDBv2mycg D9CQt7rCOdDoLKw7MgkCEKeIlbQGzYhS+o1IdMPNUIXJpejgi4La5COHDEWbZU/cl0Y8 DnatymJn50lR2Z7CcqzRM//kwhLDVsFROnBqWlbEBRLJW/HlV7i0D3+Bt656Zrki3Syi MW1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=merlin.20170209 header.b=bk7Yp65U; 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 j1si1563222ejx.446.2020.10.22.13.07.22; Thu, 22 Oct 2020 13:07:45 -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=bk7Yp65U; 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 S2897295AbgJVLc0 (ORCPT + 99 others); Thu, 22 Oct 2020 07:32:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2897289AbgJVLcZ (ORCPT ); Thu, 22 Oct 2020 07:32:25 -0400 Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A27D3C0613CE; Thu, 22 Oct 2020 04:32:24 -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=H93ZL99+6WZCe8jHCr+h/wqqN11hUYMAzdxBzDI+Dbw=; b=bk7Yp65UlUI6KKE0OKLKl4eUea J5lLLVZmo57VrWKstXTbgO3+ReDHxzFw6F/uSiQTAumbww9DnzUNDsogqYdvLO9LPZmhf00HQwCcM 4BeSujd9Vhb+PUGgl6nj3/r/AvvsqOtqlJMA2AtbvZfQ9z3jAfsRzjyWcuxT7q9lD0VfN/89uMwuC nD9iCpV+q5eBlrIFXppZ1OYAlYU0X+ecw5OrEG7/FhIZPk93hrZu1C2QnSG61/OKwT6yyUECuguo9 1xU4CgacwiUKd3Fu5WFbnJshLkQvzlrUerSWBDkomAwF52yjnGv85rL1w3R9lqBXgJdxl1SdRY2IA VPxzjaXA==; 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 1kVYpL-0006Fc-Nt; Thu, 22 Oct 2020 11:32:15 +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 26722302753; Thu, 22 Oct 2020 13:32:14 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 15E6B203D0810; Thu, 22 Oct 2020 13:32:14 +0200 (CEST) Date: Thu, 22 Oct 2020 13:32:14 +0200 From: Peter Zijlstra To: Sai Prakash Ranjan Cc: Mathieu Poirier , Suzuki K Poulose , 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: <20201022113214.GD2611@hirez.programming.kicks-ass.net> References: 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 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?