All of lore.kernel.org
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Denys Zagorui <dzagorui@cisco.com>
Cc: Jiri Olsa <jolsa@redhat.com>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>
Subject: Re: [PATCH v5 2/3] perf tests: avoid storing an absolute path in perf binary
Date: Thu, 20 May 2021 23:59:27 -0700	[thread overview]
Message-ID: <CAM9d7chuLSM6PYvgUs0g9ZzuK5M5nQ0cP+4ahufNN9BOMYuqyA@mail.gmail.com> (raw)
In-Reply-To: <20210517084604.2895-2-dzagorui@cisco.com>

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
>

  reply	other threads:[~2021-05-21  6:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-17  8:46 [PATCH v5 1/3] perf report: compile tips.txt in perf binary Denys Zagorui
2021-05-17  8:46 ` [PATCH v5 2/3] perf tests: avoid storing an absolute path " Denys Zagorui
2021-05-21  6:59   ` Namhyung Kim [this message]
2021-05-17  8:46 ` [PATCH v5 3/3] perf parse-events: add bison --file-prefix-map option Denys Zagorui
2021-05-19 13:24 ` [PATCH v5 1/3] perf report: compile tips.txt in perf binary Jiri Olsa
2021-05-21 10:24   ` Denys Zagorui -X (dzagorui - GLOBALLOGIC INC at Cisco)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAM9d7chuLSM6PYvgUs0g9ZzuK5M5nQ0cP+4ahufNN9BOMYuqyA@mail.gmail.com \
    --to=namhyung@kernel.org \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=dzagorui@cisco.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.