linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf dlfilter: Avoid leak in v0 API test use of resolve_address()
@ 2023-08-30  9:05 Adrian Hunter
  0 siblings, 0 replies; only message in thread
From: Adrian Hunter @ 2023-08-30  9:05 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Jiri Olsa, Namhyung Kim, Ian Rogers, linux-kernel,
	linux-perf-users

The introduction of reference counting causes the v0 API
perf_dlfilter_fns.resolve_address() to leak. v2 API introduced
perf_dlfilter_fns.al_cleanup() to prevent that. For the v0 API, avoid the
leak by exiting the addr_location immediately, since the documentation
makes it clear that pointers obtained via perf_dlfilter_fns are not
necessarily valid (dereferenceable) after 'filter_event' and
'filter_event_early' return.

Reported-by: kernel test robot <oliver.sang@intel.com>
Closes: https://lore.kernel.org/oe-lkp/202308232146.94d82cb4-oliver.sang@intel.com
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 tools/perf/util/dlfilter.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/perf/util/dlfilter.c b/tools/perf/util/dlfilter.c
index e0f822ebb9b9..1dbf27822ee2 100644
--- a/tools/perf/util/dlfilter.c
+++ b/tools/perf/util/dlfilter.c
@@ -187,6 +187,8 @@ static __s32 dlfilter__resolve_address(void *ctx, __u64 address, struct perf_dlf
 
 	if (has_priv(d_al_p))
 		d_al_p->priv = memdup(&al, sizeof(al));
+	else /* Avoid leak for v0 API */
+		addr_location__exit(&al);
 
 	return 0;
 }
-- 
2.34.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-08-30 18:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-30  9:05 [PATCH] perf dlfilter: Avoid leak in v0 API test use of resolve_address() Adrian Hunter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).