Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp2455160rwb; Thu, 27 Jul 2023 07:29:27 -0700 (PDT) X-Google-Smtp-Source: APBJJlGzoq+Z7dwWz6kZvQhLzCoj+lSNqXC4IZeFubTapgZ9QMhHpBOj5lRZP/0Kw707Pq2PgGyu X-Received: by 2002:a17:906:76d6:b0:98f:c9b:24ed with SMTP id q22-20020a17090676d600b0098f0c9b24edmr2367617ejn.67.1690468167057; Thu, 27 Jul 2023 07:29:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690468167; cv=none; d=google.com; s=arc-20160816; b=S4iXQYu+XYZjlCwozsiQGxJLkV2Qd5AxaVzeRAtw4ou09cJehyavVBVPrHFc+vMg6z gUg32RmWfhwTI3CD/X/2oCbMHr9hMI+so2Ro5VPySMBZBcSLqlf02fWd7EpGjiwtVS1g VOtv5XdLSS6hSO5EySlcdFz3zt/aORvqDkOhtGgqH9vdGsHPI0nAyXps9wOkrPDLw4u+ tQ4HD6wS7VO1NDfr9t04V/W9MahslpPFoh3Jds5jbnBSYMEKTJ6OD+C/V7JuBUD1D/sn 5rzOKEbmhhwXfFjgbBHyDC5X/tNYRqwiHri00/ae60TNIEZFAUGdhuapKjcLitakczJ3 69yA== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=e2d1wpJM7pXktqyyYt48UHcbCsEur2h8l8Ltry07tDo=; fh=5Y0pW1eJMpODuquNw6lg8G4xQDy9VnDVFrrPbI1COn8=; b=DGsyXsUQ8Esn26bAALpHscGIc88Zov1xx0MZOdhWwAH44SRSwePCqA2duU2AygWXx1 IEaDgzbrFjDmFjwXGw/bt3mHyfhpu9YdMIemdSNp/3o+7BsOx+g570stAbPU4z1lpKWI CVztjudxB8r1G24VNLWArxOg3HeBGv2HkU3+g4SO8JrNnavYPwu2+mWfLhrf2AaOfTDY kjO6kXq1d3sWbRJA9shoxK80+cSVofb8RYdOjCWaZ2TFTzRLETIY8cAGTR/MllfGbn8J UiJatTVnnfXmy3AIVX/L2Xick6F4OKDe96XNpY7PbEApBaA0AKhQLsM81/7RCeB9w6Jh r0zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hwgnQP2v; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id rl19-20020a170907217300b0098642e99c22si1099123ejb.604.2023.07.27.07.29.00; Thu, 27 Jul 2023 07:29:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hwgnQP2v; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232716AbjG0ONR (ORCPT + 99 others); Thu, 27 Jul 2023 10:13:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231489AbjG0ONQ (ORCPT ); Thu, 27 Jul 2023 10:13:16 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1155C2682 for ; Thu, 27 Jul 2023 07:13:16 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 818E561E8A for ; Thu, 27 Jul 2023 14:13:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A6B29C433C7; Thu, 27 Jul 2023 14:13:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690467194; bh=/o7KIWnvlUjtTt9p21Ded+WRgEfi2pgmoiqanzTo+Nc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=hwgnQP2vkt9HnJxpxFBVk8HwIX61Sl8WLMvRvxiTe3T6LdD4SNKSfkhII7Z+R/Cd8 a7lpMeLlCIq+UFZDASEIvK8tuTtW307JjPeDJK2TcbOv0d2YyZvQScAcDRVvMvjGtu YoLTU8hiOHGa34rwulW0skAwY2JgPrOsIysMhbKwt5E1+e7sNnqWGfQs3nu27bBWa7 ZjPOEkIUC10c66WRPbESxhew/k6M32VLgXlBuOxQitFtkGURLYiiosMKlHEwauY2BC YSDrKMXL8p//XksC54aX4AjcWKLYgVApNh41PZBJunDUmvdv/Hy2qIs5g0TRtjSSgj g0HJqocrt1gmA== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id ACC6840516; Thu, 27 Jul 2023 11:13:11 -0300 (-03) Date: Thu, 27 Jul 2023 11:13:11 -0300 From: Arnaldo Carvalho de Melo To: Adrian Hunter Cc: Ian Rogers , "Aneesh Kumar K.V" , Athira Rajeev , Disha Goel , Jiri Olsa , Kajol Jain , Madhavan Srinivasan , Namhyung Kim , Linux Kernel Mailing List Subject: Re: [PATCH 1/1] perf dlfilter: Initialize addr_location before passing it to thread__find_symbol_fb() Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Url: http://acmel.wordpress.com X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Tue, Jul 25, 2023 at 02:51:58PM +0300, Adrian Hunter escreveu: > On 25/07/23 00:31, Arnaldo Carvalho de Melo wrote: > > Em Mon, Jul 24, 2023 at 02:16:05PM -0700, Ian Rogers escreveu: > >> On Mon, Jul 24, 2023 at 2:09 PM Arnaldo Carvalho de Melo > >> wrote: > >>> > >>> As thread__find_symbol_fb() will end up calling thread__find_map() and > >>> it in turn will call these on uninitialized memory: > >>> > >>> maps__zput(al->maps); > >>> map__zput(al->map); > >>> thread__zput(al->thread); > >> > >> Normally there would be a addr_location__exit. It looks here like most > >> values are copied in al_to_d_al, which copies reference counted values > >> without doing appropriate gets. Perhaps add the gets in al_to_d_al and > >> add the exit to make it clear there can't be addr_location related > >> leaks here. Or just make al_to_d_al use strdups for the strings it gets from reference counter structs. That or make the caller of ->resolve_address() provide a initialized addr_location that it then exits. - Arnaldo > > I'll do that as well and add the addr_location__exit() then send a V2. > > The data is not valid outside the context of ->filter_event() or > ->filter_event_early(), so the reference counts should not be changed. > That probably needs to be made clearer in the documentation. > > > > - Arnaldo > > > >> Thanks, > >> Ian > >> > >>> Fixes: 0dd5041c9a0eaf8c ("perf addr_location: Add init/exit/copy functions") > >>> Cc: Adrian Hunter > >>> Cc: Aneesh Kumar K.V > >>> Cc: Athira Rajeev > >>> Cc: Disha Goel > >>> Cc: Ian Rogers > >>> Cc: Jiri Olsa > >>> Cc: Kajol Jain > >>> Cc: Madhavan Srinivasan > >>> Cc: Namhyung Kim > >>> Link: https://lore.kernel.org/lkml/ > >>> Signed-off-by: Arnaldo Carvalho de Melo > >>> --- > >>> tools/perf/util/dlfilter.c | 1 + > >>> 1 file changed, 1 insertion(+) > >>> > >>> diff --git a/tools/perf/util/dlfilter.c b/tools/perf/util/dlfilter.c > >>> index 46f74b2344dbb34c..798a53d7e6c9dfc5 100644 > >>> --- a/tools/perf/util/dlfilter.c > >>> +++ b/tools/perf/util/dlfilter.c > >>> @@ -166,6 +166,7 @@ static __s32 dlfilter__resolve_address(void *ctx, __u64 address, struct perf_dlf > >>> if (!thread) > >>> return -1; > >>> > >>> + addr_location__init(&al); > >>> thread__find_symbol_fb(thread, d->sample->cpumode, address, &al); > >>> > >>> al_to_d_al(&al, &d_al); > >>> -- > >>> 2.37.1 > >>> > > > -- - Arnaldo