Message ID | 20230316194156.8320-2-adrian.hunter@intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp681775wrt; Thu, 16 Mar 2023 13:12:05 -0700 (PDT) X-Google-Smtp-Source: AK7set8msBX1XO7MdZ/Bk522aS2VlliwtU99f25XbbsqwDBKmi3k8jv81d2TiNpmlVvhNPdcBKbi X-Received: by 2002:a17:903:22d2:b0:19e:8452:1944 with SMTP id y18-20020a17090322d200b0019e84521944mr5928450plg.5.1678997525604; Thu, 16 Mar 2023 13:12:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678997525; cv=none; d=google.com; s=arc-20160816; b=jfoO3K/YKyndbQG4gFJASRAkqGmyixN1aOf9fQMJ+8xf+CHH8R/pwrjHjBj1rwYHxk 6aTaF1yD1F3cc7UT86c5VK47qnyly9Uq8l/cvvOSHT6ur2eY01NanQb/suy4IL9UN9jR OMO38TATAOVMCyv1AR0+d4r2lQT4Feo4VEWEf+YBqNfREt8NVfq1QhZDVq/DgDwOJfp7 I4kjmfHISrt8jbsx0hEhkR9CLMyEiXMqjhbYUEX9yOwQzWzvPVajzTRpxjZsKVbNrtcK SZMFv2pHLxOIecoF5AEfz4qOLMTuBgEBhkdwjiTKjOTRPGPoYklTQeeWY1kyE9X3vYtg Ne6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:organization :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bVjcBy+hTIksLzJT1oEhkBeJIebyZAc+YCZpa2hhl+o=; b=vH0NifYTCrwoV9qeW7PLECU4IlKMMgmaGkU/Ai3cUTHM3QVXzMYecCmonXfFHvGwuF PqVVxzHHbCoEZ8jQ52eaO/eFW7944IkmNBzhc4w5+SOlrWfawDhM+1PE1jvuNZHIz47s IYkdx3GzkpTgYq/srd93ZQ4e9j6LtPyneO4CYNq2BXSaHfX9x7P6YOch5pxzo7OHvGjX edC0JIjHxmXr3mnEqSTXcaFdGwec/6y5m2KeLpOa+55L/ndoIYOLKWGcJ8E8h6UFH1ck n/LcBvK6aLMRIWSrHHxU3lrdTzh+W2a1f58c41d6uHcX/O0psLEeI1UKuAmrLSpc4ERg zfyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ZVai50OV; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ay6-20020a1709028b8600b001a0561c726dsi267121plb.264.2023.03.16.13.11.52; Thu, 16 Mar 2023 13:12:05 -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=ZVai50OV; 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 S230211AbjCPTmS (ORCPT <rfc822;pwkd43@gmail.com> + 99 others); Thu, 16 Mar 2023 15:42:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229708AbjCPTmP (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 16 Mar 2023 15:42:15 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8296E442CB; Thu, 16 Mar 2023 12:42:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1678995734; x=1710531734; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=eIZyYOcJoDlch2zoEcNQZVhXa/4V+wzyFtHKXdVX4jU=; b=ZVai50OVrZ/OOMm+iJC3qqv6EpZsNG//b23JljgSC7dhH3Ge8M0Q1lfH 6sILO94ZEox0Z4R+ya5mU4IcA8snIdt+CoA70+FBG2vgd1IFFZPwM2GCP Wg/bGCdWDaW1GGeLGBtuxZzgSyBULOlq8iTIIsg3PWBw3HbSBSYcvslPj 9VngzW52hDt0dEpOz8yGBNqGTmd0h5GxH9wz+EuS9iEFLg8ffkMVtrGNs uuiQ/KjNqSv1rCiMZNO3JYDbSdMqirPdxcvZYUqB6PUQFFIRUprOe8O1U gqWeMOhCwieiGGWXRH+WOGEEqhR0WeKWIH4b6sPF8jKEC3n3PmeOtpHhl w==; X-IronPort-AV: E=McAfee;i="6600,9927,10651"; a="326465402" X-IronPort-AV: E=Sophos;i="5.98,265,1673942400"; d="scan'208";a="326465402" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Mar 2023 12:42:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10651"; a="823392391" X-IronPort-AV: E=Sophos;i="5.98,265,1673942400"; d="scan'208";a="823392391" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO ahunter-VirtualBox.home\044ger.corp.intel.com) ([10.251.221.172]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Mar 2023 12:42:12 -0700 From: Adrian Hunter <adrian.hunter@intel.com> To: Arnaldo Carvalho de Melo <acme@kernel.org> Cc: Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>, Ian Rogers <irogers@google.com>, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Subject: [PATCH 1/3] perf symbols: Fix use-after-free in get_plt_got_name() Date: Thu, 16 Mar 2023 21:41:54 +0200 Message-Id: <20230316194156.8320-2-adrian.hunter@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230316194156.8320-1-adrian.hunter@intel.com> References: <20230316194156.8320-1-adrian.hunter@intel.com> MIME-Version: 1.0 Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Content-Transfer-Encoding: 8bit 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, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760556509795025974?= X-GMAIL-MSGID: =?utf-8?q?1760556509795025974?= |
Series |
perf tools: Address fixes
|
|
Commit Message
Adrian Hunter
March 16, 2023, 7:41 p.m. UTC
Fix use-after-free in get_plt_got_name().
Discovered using EXTRA_CFLAGS="-fsanitize=undefined -fsanitize=address".
Reported-by: kernel test robot <yujie.liu@intel.com>
Link: https://lore.kernel.org/oe-lkp/202303061424.6ad43294-yujie.liu@intel.com
Fixes: ce4c8e7966f3 ("perf symbols: Get symbols for .plt.got for x86-64")
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
tools/perf/util/symbol-elf.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c index c0a2de42c51b..7ef5f6d7d415 100644 --- a/tools/perf/util/symbol-elf.c +++ b/tools/perf/util/symbol-elf.c @@ -557,6 +557,7 @@ static bool get_plt_got_name(GElf_Shdr *shdr, size_t i, const char *sym_name; char *demangled; GElf_Sym sym; + bool result; u32 disp; if (!di->sorted) @@ -583,9 +584,11 @@ static bool get_plt_got_name(GElf_Shdr *shdr, size_t i, snprintf(buf, buf_sz, "%s@plt", sym_name); + result = *sym_name; + free(demangled); - return *sym_name; + return result; } static int dso__synthesize_plt_got_symbols(struct dso *dso, Elf *elf,