lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAM9d7ci5XB7-PdcXchWW7bBFO_64B0M76rpY8xgkBYr3-mGW0Q@mail.gmail.com>
Date:   Thu, 25 May 2023 12:17:46 -0700
From:   Namhyung Kim <namhyung@...nel.org>
To:     Ian Rogers <irogers@...gle.com>
Cc:     Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...hat.com>,
        Arnaldo Carvalho de Melo <acme@...nel.org>,
        Mark Rutland <mark.rutland@....com>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Jiri Olsa <jolsa@...nel.org>,
        Adrian Hunter <adrian.hunter@...el.com>,
        "Masami Hiramatsu (Google)" <mhiramat@...nel.org>,
        "Steven Rostedt (Google)" <rostedt@...dmis.org>,
        Ross Zwisler <zwisler@...omium.org>,
        Leo Yan <leo.yan@...aro.org>,
        Tiezhu Yang <yangtiezhu@...ngson.cn>,
        Yang Jihong <yangjihong1@...wei.com>,
        Andi Kleen <ak@...ux.intel.com>,
        Kan Liang <kan.liang@...ux.intel.com>,
        Ravi Bangoria <ravi.bangoria@....com>,
        Sean Christopherson <seanjc@...gle.com>,
        K Prateek Nayak <kprateek.nayak@....com>,
        Paolo Bonzini <pbonzini@...hat.com>,
        linux-kernel@...r.kernel.org, linux-perf-users@...r.kernel.org
Subject: Re: [PATCH v1 08/16] perf daemon: Dynamically allocate path to perf

On Thu, May 25, 2023 at 12:12 AM Ian Rogers <irogers@...gle.com> wrote:
>
> Avoid a PATH_MAX array in __daemon (the .data section) by dynamically
> allocating the memory.
>
> Signed-off-by: Ian Rogers <irogers@...gle.com>
> ---
>  tools/perf/builtin-daemon.c | 15 +++++++++++++--
>  1 file changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/builtin-daemon.c b/tools/perf/builtin-daemon.c
> index 34cbe3e959aa..adb5751c3ed0 100644
> --- a/tools/perf/builtin-daemon.c
> +++ b/tools/perf/builtin-daemon.c
> @@ -90,7 +90,7 @@ struct daemon {
>         char                    *base;
>         struct list_head         sessions;
>         FILE                    *out;
> -       char                     perf[PATH_MAX];
> +       char                    *perf;
>         int                      signal_fd;
>         time_t                   start;
>  };
> @@ -1490,6 +1490,15 @@ static int __cmd_ping(struct daemon *daemon, struct option parent_options[],
>         return send_cmd(daemon, &cmd);
>  }
>
> +static char *set_perf_exe(void)
> +{
> +       char path[PATH_MAX];
> +
> +       perf_exe(path, sizeof(path));
> +       __daemon.perf = strdup(path);
> +       return __daemon.perf;

Then you need to free it somewhere.

Thanks,
Namhyung


> +}
> +
>  int cmd_daemon(int argc, const char **argv)
>  {
>         struct option daemon_options[] = {
> @@ -1503,7 +1512,9 @@ int cmd_daemon(int argc, const char **argv)
>                 OPT_END()
>         };
>
> -       perf_exe(__daemon.perf, sizeof(__daemon.perf));
> +       if (!set_perf_exe())
> +               return -ENOMEM;
> +
>         __daemon.out = stdout;
>
>         argc = parse_options(argc, argv, daemon_options, daemon_usage,
> --
> 2.40.1.698.g37aff9b760-goog
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ