[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20181014140451.GB24104@krava>
Date: Sun, 14 Oct 2018 16:04:51 +0200
From: Jiri Olsa <jolsa@...hat.com>
To: Ivan Krylov <krylov.r00t@...il.com>
Cc: Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Namhyung Kim <namhyung@...nel.org>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] perf annotate: pass filename to objdump via execl
On Sun, Oct 14, 2018 at 11:18:03AM +0300, Ivan Krylov wrote:
> The symbol__disassemble() function uses shell to launch objdump and filter
> its output via grep. Passing filenames by interpolating them into the
> command line via "%s" may lead to problems if said filenames contain
> special characters.
>
> Instead, pass the filename as a command line argument where it is not
> subject to any kind of interpretation, then use quoted shell
> interpolation to build the strings we need safely.
>
> Signed-off-by: Ivan Krylov <krylov.r00t@...il.com>
Acked-by: Jiri Olsa <jolsa@...nel.org>
thanks,
jirka
> ---
> tools/perf/util/annotate.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
> index 28cd6a174..4a870181e 100644
> --- a/tools/perf/util/annotate.c
> +++ b/tools/perf/util/annotate.c
> @@ -1696,15 +1696,14 @@ static int symbol__disassemble(struct symbol *sym, struct annotate_args *args)
> err = asprintf(&command,
> "%s %s%s --start-address=0x%016" PRIx64
> " --stop-address=0x%016" PRIx64
> - " -l -d %s %s -C \"%s\" 2>/dev/null|grep -v \"%s:\"|expand",
> + " -l -d %s %s -C \"$1\" 2>/dev/null|grep -v \"$1:\"|expand",
> opts->objdump_path ?: "objdump",
> opts->disassembler_style ? "-M " : "",
> opts->disassembler_style ?: "",
> map__rip_2objdump(map, sym->start),
> map__rip_2objdump(map, sym->end),
> opts->show_asm_raw ? "" : "--no-show-raw",
> - opts->annotate_src ? "-S" : "",
> - symfs_filename, symfs_filename);
> + opts->annotate_src ? "-S" : "");
>
> if (err < 0) {
> pr_err("Failure allocating memory for the command to run\n");
> @@ -1729,7 +1728,8 @@ static int symbol__disassemble(struct symbol *sym, struct annotate_args *args)
> close(stdout_fd[0]);
> dup2(stdout_fd[1], 1);
> close(stdout_fd[1]);
> - execl("/bin/sh", "sh", "-c", command, NULL);
> + execl("/bin/sh", "sh", "-c", command, "--", symfs_filename,
> + NULL);
> perror(command);
> exit(-1);
> }
> --
> 2.11.0
Powered by blists - more mailing lists