lkml.org 
[lkml]   [2021]   [May]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v5 2/3] perf tests: avoid storing an absolute path in perf binary
Hello,

On Mon, May 17, 2021 at 1:46 AM Denys Zagorui <dzagorui@cisco.com> wrote:
>
> python binding test uses PYTHONPATH definition to find python/perf.so
> library. This definition is an absolute path that makes perf binary
> unreproducible. This path can be found during runtime execution.
>
> Signed-off-by: Denys Zagorui <dzagorui@cisco.com>
> ---
[SNIP]
> +char *perf_exe_path(void)
> +{
> + char *buf;
> + char *dname;
> +
> + buf = malloc(PATH_MAX);
> + if (buf == NULL)
> + return NULL;
> +
> + buf = perf_exe(buf, PATH_MAX);
> +
> + dname = dirname(buf);
> +
> + free(buf);
> + return dname;

I don't think it's safe to use dname after freeing buf.

Thanks,
Namhyung


> +}
> diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
> index 80b194ee6c7d..4b506df4e8b9 100644
> --- a/tools/perf/util/util.h
> +++ b/tools/perf/util/util.h
> @@ -49,6 +49,7 @@ void perf_set_singlethreaded(void);
> void perf_set_multithreaded(void);
>
> char *perf_exe(char *buf, int len);
> +char *perf_exe_path(void);
>
> #ifndef O_CLOEXEC
> #ifdef __sparc__
> --
> 2.26.2.Cisco
>

\
 
 \ /
  Last update: 2021-05-21 09:00    [W:0.871 / U:0.100 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site