Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp4382094rwo; Tue, 25 Jul 2023 05:26:52 -0700 (PDT) X-Google-Smtp-Source: APBJJlFRjfIA98WI3NAL6Ky3fqV5+hposGxTSwM4UKyIU2y1IhoAZej/XdQ2Tmw0UGniAaixL4uv X-Received: by 2002:a17:906:31c7:b0:994:13c3:2f89 with SMTP id f7-20020a17090631c700b0099413c32f89mr2148621ejf.27.1690288012480; Tue, 25 Jul 2023 05:26:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690288012; cv=none; d=google.com; s=arc-20160816; b=ZKX7jvYjGqnAsMi9SJC30h5npZEwMuo6Ct1lEw2Jhwmr0R2VYxAIZp2ji+uvNCTQ7U vnOSDKpk8Zp1TyKJ+cRxM3Qu9uNK9ksx2oEpm9bPImA4Not40OcyjlhVy8VDAj3JOpgv bYX5JxJ6pP+eWjdCZAET1m4xiPRl8A0W8CRQbf5mxW1ucLlwOoJ3thSMPHa/ertBBmdD 0VlR295Jxko+tk29NfNSYSCLGoF3NvFSaQhEvH9TBRFsatq+ItRPcOf/dznihnk7fyox tz25QcZK5STNmNeBzmX0rMwF+gmOrV/Y7fVhYnnRz27qlG0g/uUOHS0Xtig8LBcu6x+m LCww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=/R3ifiiTnvDez+U4nhu5sDvz9e1VAvKfa+67qn7uhSo=; fh=orvQmW3pC1JdlCTJ1NcE2H3skw0XVWBxGzpqS25Gje4=; b=xDyH0z1WGuxwWYHv+VwuYba00cjj1cWQfgnw4VFhb2V//KmXStpABhAm/lv8bzCYdT CHNkmauwt5HKHld1+OZptKi5ONOkF0b800w1chbBHj+0dHWhQQY5ecTcfHLqHIJ8fqX+ xU4awZVCh58oJnElIqRK6aE/zZvnFApIpt2jrXgvDmhOkU451gA8NFF2vEuBaKlG6SX+ 57cBjxm37TccJaJZMXjvT2zvmqTXOaTR71srtNa3qYXSSS4hpzDFzbh19ysgGtwnZZBp gRP/CDL9npu21LPQBJNM3iJhbn291JwcC5u/9EDdoWAhK/OE3NkQinGsdALAr0lAz5YP O4OQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fbVFzRs4; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a10-20020a170906274a00b009932528281asi7975595ejd.579.2023.07.25.05.26.24; Tue, 25 Jul 2023 05:26:52 -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=@intel.com header.s=Intel header.b=fbVFzRs4; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231708AbjGYLwl (ORCPT + 99 others); Tue, 25 Jul 2023 07:52:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232106AbjGYLwX (ORCPT ); Tue, 25 Jul 2023 07:52:23 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C5F310EC for ; Tue, 25 Jul 2023 04:52:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1690285928; x=1721821928; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=Fd/RDz89cgDhh0kuNdhH2IWsW1WRaHvoArD8ju6Ge28=; b=fbVFzRs4VXkMnS4d6aA+faeIsdgZRBflas6O5bG/GO3SNcLEB9acJ/rG TaBLR1H9NDcn08lQPXFxjWwjWSWK8CXhIcXoTWFBAH5Zl0yBa4nQjPkls SiRhGHb0na+ZjNjEO1oxfS7lw7jazwk1Tx3m5Z7zC90OKIEKAnRhda59F 5PUJ0byBxmN8j4hAfKgs/KLMbG4dbjqczWuwrBynMQ5sES5zB/iw8Hrdl UedOPuRmxbe/sq40XXMpkxiRhoXOIuuTWUaKsNIqp776NHgp03cR4KcNU 7CtMFaqxlAABm16wyOgqzIXm7jAxwKvo4sybhPdpWjOtE8++t1nW/eolw A==; X-IronPort-AV: E=McAfee;i="6600,9927,10781"; a="357700524" X-IronPort-AV: E=Sophos;i="6.01,230,1684825200"; d="scan'208";a="357700524" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jul 2023 04:52:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10781"; a="729323683" X-IronPort-AV: E=Sophos;i="6.01,230,1684825200"; d="scan'208";a="729323683" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO [10.0.2.15]) ([10.249.37.150]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jul 2023 04:52:02 -0700 Message-ID: Date: Tue, 25 Jul 2023 14:51:58 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0 Thunderbird/102.13.0 Subject: Re: [PATCH 1/1] perf dlfilter: Initialize addr_location before passing it to thread__find_symbol_fb() Content-Language: en-US To: Arnaldo Carvalho de Melo , Ian Rogers Cc: "Aneesh Kumar K.V" , Athira Rajeev , Disha Goel , Jiri Olsa , Kajol Jain , Madhavan Srinivasan , Namhyung Kim , Linux Kernel Mailing List References: From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 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. > > 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 >>> >