Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp5764001pxu; Thu, 22 Oct 2020 10:23:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzeRjC8ygvgDsEtv7hxmxjS56+AxwQxDLmzDXBKl9HHUO5SWQf5cx/IBQjPo9TQkZtYIgO8 X-Received: by 2002:a17:906:1a11:: with SMTP id i17mr3211130ejf.381.1603387433780; Thu, 22 Oct 2020 10:23:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603387433; cv=none; d=google.com; s=arc-20160816; b=h66r1PVu19VtjktpFnr/IMCl9STFok1r12iRlphGUPvgOvSajU3+zER8cPiCOSy+NA S2cX5V2AM44SfqLvlvQqdTYAmkhF2BOpEHLYb11gXEQQLfTaBKzRXas5N9jEdr2OsO+u 4jFoQm53/EJ0VfV1FLnnZXzG/S+ht/K55oKV+1lkYkELxXhdefiEToYekirQCppN2sis VQ6Uj/F7jRXZxCWRidw2/K2KvoB//sSdcKauoyHp9CCjV0lcS+z1Wkw/lYiKEUgfAnkk K7KWN3sS9xXkIGFQBzU33bBPO/p5P/pvfdgkckX0h8SddDVy8114xvCNEO+t9qbUFFB+ dUcw== 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=Qxyx+8WuGLMGwiLrpDGgc0hdt6eMPydpMviwqwPoqUg=; b=koxa1I7RtIkY5ZOGK/Ob4CkEuTRIUy/v9lYSvKmsAL5cymazIRnmAeI1guWsF+W8mH l5/QkbsLW/HpHVEzLVapd5rfjU1kbfInf+yoy21qRBmmSMBVDAND/569Vs6aLdKyt2X5 lRJr4jsU759FfXOEP/CIKuXwcBt5i/Uj3dkAm1NbeERVfC3wxStHcNBWc36Y5pCM9Z/Y sGlzC+QKL7Oe/fzefADHfTjF7MdvVy7LGf3+isgEeSH/JFXWF0KUW53FZ0irbRehyFFd 0lI0X9MLaIsGuo8BglL+TAEDP0DJ+j2qPnkxveGmV5+IsP7CsCYBxMq77pmPMYFQFBUA UOWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=merlin.20170209 header.b=Fl0Adssb; 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 t6si349369ejf.462.2020.10.22.10.23.31; Thu, 22 Oct 2020 10:23:53 -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=Fl0Adssb; 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 S2900130AbgJVNe1 (ORCPT + 99 others); Thu, 22 Oct 2020 09:34:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725971AbgJVNe0 (ORCPT ); Thu, 22 Oct 2020 09:34:26 -0400 Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6130AC0613CE; Thu, 22 Oct 2020 06:34:26 -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=Qxyx+8WuGLMGwiLrpDGgc0hdt6eMPydpMviwqwPoqUg=; b=Fl0AdssbEzOpX7eS1DBwN93QE8 p64WFhpy6pR2iDC/1zS2vumFyDI6RIdwMJQjVXA+shrhJxMMnWhUOl6wIsCwXIaRjW+9RJs4xJMyr G+8PV/UJmCWoYpGpSv9PuIzwKE4CWHeoJRKcuKa0OrrPz9yUUYS1z+G683m7XJIwyATTWg45KDnt6 aZyHcDhdA+2gBMfsU4Fz3kBZrguUBPzEAKmO7F79i7c8JdPu2lmk3ZzYaRehdq6OMkr3Cr5PK0zDD KqsA00IE1Yayi3Wu5VbzZxVKf690ofgUJgrdVXefr60yxRrvn0xSmxqekMx2x7kogGQsfY865vvb6 i3Q6YTpw==; 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 1kVajS-000189-2G; Thu, 22 Oct 2020 13:34:18 +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 699363011C6; Thu, 22 Oct 2020 15:34:14 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 60603203CC499; Thu, 22 Oct 2020 15:34:14 +0200 (CEST) Date: Thu, 22 Oct 2020 15:34:14 +0200 From: Peter Zijlstra To: Sai Prakash Ranjan 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() Message-ID: <20201022133414.GH2611@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 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_.