From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A8F7853A7; Fri, 6 Dec 2024 15:08:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733497694; cv=none; b=f3vXRCl58zjHzGyAyE6wFDLlLGLVlXLFmaY2KZyavN6te0OOreWkQUZ7mCOWQWDnTx2JsY+eci0yAdiaHxJ1+w55tixDoMM7evZSkm7uv01dswf9J3eJT4uy+byFP6PBgQpeihzC6JOarvFxAVi3+9ojDgn4HnznEGI2wv9nIJI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733497694; c=relaxed/simple; bh=K68Uj+ikDjmEQkHdcygpdKpsWF5m+YPp4e4nojavZfI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AjvknyeeogSMDP7wVzTCxxkGgioeew5q7eCef3tXKVR7inb7cYZK6jHNJ5cPdffkYi7a4Omf6rmiur9z+ta21/Sp4KzJvoMM1cEp487yfQXWVSr6oeRijkAAqtlwITOafwVj91GFxdyMJKEDkXDT1mOy3UcmembzmH1Jemf2SwA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=VytwOaOx; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="VytwOaOx" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D768BC4CEDC; Fri, 6 Dec 2024 15:08:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1733497694; bh=K68Uj+ikDjmEQkHdcygpdKpsWF5m+YPp4e4nojavZfI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VytwOaOxlP5Cz4/kxer+C9QepmOgO4XzAWHidnCLUBPK4nhh+WTbcps8clinfytO+ R/EPMD/BX201IzsshiX3Zah7p+H+kDj1HEi+cfoih/Bs/+wMh6Yi956rBr0TOFZA/M W/ZWZwShXEYNkUR/nTEdgxRnglKRUqMZx6URuaJk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ian Rogers , "David S. Miller" , "Steinar H. Gunderson" , Alexander Lobakin , "Masami Hiramatsu (Google)" , Kajol Jain , Athira Rajeev , Hemant Kumar , Namhyung Kim , Sasha Levin Subject: [PATCH 6.6 348/676] perf probe: Fix libdw memory leak Date: Fri, 6 Dec 2024 15:32:47 +0100 Message-ID: <20241206143706.940565097@linuxfoundation.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241206143653.344873888@linuxfoundation.org> References: <20241206143653.344873888@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ian Rogers [ Upstream commit 4585038b8e186252141ef86e9f0d8e97f11dce8d ] Add missing dwarf_cfi_end to free memory associated with probe_finder cfi_eh which is allocated and owned via a call to dwarf_getcfi_elf. Confusingly cfi_dbg shouldn't be freed as its memory is owned by the passed in debuginfo struct. Add comments to highlight this. This addresses leak sanitizer issues seen in: tools/perf/tests/shell/test_uprobe_from_different_cu.sh Fixes: 270bde1e76f4 ("perf probe: Search both .eh_frame and .debug_frame sections for probe location") Signed-off-by: Ian Rogers Cc: David S. Miller Cc: Steinar H. Gunderson Cc: Alexander Lobakin Cc: Masami Hiramatsu (Google) Cc: Kajol Jain Cc: Athira Rajeev Cc: Hemant Kumar Link: https://lore.kernel.org/r/20241016235622.52166-3-irogers@google.com Signed-off-by: Namhyung Kim Signed-off-by: Sasha Levin --- tools/perf/util/probe-finder.c | 4 ++++ tools/perf/util/probe-finder.h | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c index f171360b0ef4d..c816191564bdf 100644 --- a/tools/perf/util/probe-finder.c +++ b/tools/perf/util/probe-finder.c @@ -1499,6 +1499,10 @@ int debuginfo__find_trace_events(struct debuginfo *dbg, if (ret >= 0 && tf.pf.skip_empty_arg) ret = fill_empty_trace_arg(pev, tf.tevs, tf.ntevs); +#if _ELFUTILS_PREREQ(0, 142) + dwarf_cfi_end(tf.pf.cfi_eh); +#endif + if (ret < 0 || tf.ntevs == 0) { for (i = 0; i < tf.ntevs; i++) clear_probe_trace_event(&tf.tevs[i]); diff --git a/tools/perf/util/probe-finder.h b/tools/perf/util/probe-finder.h index 8bc1c80d3c1c0..1f4650b955094 100644 --- a/tools/perf/util/probe-finder.h +++ b/tools/perf/util/probe-finder.h @@ -81,9 +81,9 @@ struct probe_finder { /* For variable searching */ #if _ELFUTILS_PREREQ(0, 142) - /* Call Frame Information from .eh_frame */ + /* Call Frame Information from .eh_frame. Owned by this struct. */ Dwarf_CFI *cfi_eh; - /* Call Frame Information from .debug_frame */ + /* Call Frame Information from .debug_frame. Not owned. */ Dwarf_CFI *cfi_dbg; #endif Dwarf_Op *fb_ops; /* Frame base attribute */ -- 2.43.0