From: Jiri Olsa <jolsa@redhat.com>
To: Ian Rogers <irogers@google.com>
Cc: He Kuang <hekuang@huawei.com>,
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>,
Namhyung Kim <namhyung@kernel.org>,
Andi Kleen <ak@linux.intel.com>,
linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com,
Stephane Eranian <eranian@google.com>
Subject: Re: [PATCH] perf tools: avoid reading out of scope array
Date: Wed, 23 Oct 2019 10:29:12 +0200 [thread overview]
Message-ID: <20191023082912.GB22919@krava> (raw)
In-Reply-To: <20191017170531.171244-1-irogers@google.com>
On Thu, Oct 17, 2019 at 10:05:31AM -0700, Ian Rogers wrote:
> Modify tracepoint name into 2 sys components and assemble at use. This
> avoids the sys_name array being out of scope at the point of use.
> Bug caught with LLVM's address sanitizer with fuzz generated input of
> ":cs\1" to parse_events.
>
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
> tools/perf/util/parse-events.y | 36 +++++++++++++++++++++++-----------
> 1 file changed, 25 insertions(+), 11 deletions(-)
>
> diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
> index 48126ae4cd13..28be39a703c9 100644
> --- a/tools/perf/util/parse-events.y
> +++ b/tools/perf/util/parse-events.y
> @@ -104,7 +104,8 @@ static void inc_group_count(struct list_head *list,
> struct list_head *head;
> struct parse_events_term *term;
> struct tracepoint_name {
> - char *sys;
> + char *sys1;
> + char *sys2;
> char *event;
> } tracepoint_name;
> struct parse_events_array array;
> @@ -425,9 +426,19 @@ tracepoint_name opt_event_config
> if (error)
> error->idx = @1.first_column;
>
> - if (parse_events_add_tracepoint(list, &parse_state->idx, $1.sys, $1.event,
> - error, $2))
> - return -1;
> + if ($1.sys2) {
> + char sys_name[128];
> + snprintf(&sys_name, sizeof(sys_name), "%s-%s",
> + $1.sys1, $1.sys2);
> + if (parse_events_add_tracepoint(list, &parse_state->idx,
> + sys_name, $1.event,
> + error, $2))
> + return -1;
> + } else
> + if (parse_events_add_tracepoint(list, &parse_state->idx,
> + $1.sys1, $1.event,
> + error, $2))
> + return -1;
nice catch, please enclose all multiline condition legs with {}
other than that
Acked-by: Jiri Olsa <jolsa@kernel.org>
thanks,
jirka
>
> $$ = list;
> }
> @@ -435,19 +446,22 @@ tracepoint_name opt_event_config
> tracepoint_name:
> PE_NAME '-' PE_NAME ':' PE_NAME
> {
> - char sys_name[128];
> - struct tracepoint_name tracepoint;
> -
> - snprintf(&sys_name, 128, "%s-%s", $1, $3);
> - tracepoint.sys = &sys_name;
> - tracepoint.event = $5;
> + struct tracepoint_name tracepoint = {
> + .sys1 = $1,
> + .sys2 = $3,
> + .event = $5,
> + };
>
> $$ = tracepoint;
> }
> |
> PE_NAME ':' PE_NAME
> {
> - struct tracepoint_name tracepoint = {$1, $3};
> + struct tracepoint_name tracepoint = {
> + .sys1 = $1,
> + .sys2 = NULL,
> + .event = $3,
> + };
>
> $$ = tracepoint;
> }
> --
> 2.23.0.700.g56cf767bdb-goog
>
next prev parent reply other threads:[~2019-10-23 8:29 UTC|newest]
Thread overview: 117+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-17 17:05 [PATCH] perf tools: avoid reading out of scope array Ian Rogers
2019-10-23 0:53 ` [PATCH v2 0/9] Improvements to memory usage by parse events Ian Rogers
2019-10-23 0:53 ` [PATCH v2 1/9] perf tools: add parse events append error Ian Rogers
2019-10-23 8:36 ` Jiri Olsa
2019-10-23 0:53 ` [PATCH v2 2/9] perf tools: splice events onto evlist even on error Ian Rogers
2019-10-23 8:40 ` Jiri Olsa
2019-10-23 0:53 ` [PATCH v2 3/9] perf tools: ensure config and str in terms are unique Ian Rogers
2019-10-23 8:50 ` Jiri Olsa
2019-10-23 0:53 ` [PATCH v2 4/9] perf tools: move ALLOC_LIST into a function Ian Rogers
2019-10-23 8:55 ` Jiri Olsa
2019-10-23 12:37 ` Arnaldo Carvalho de Melo
2019-11-12 11:18 ` [tip: perf/core] perf tools: Move " tip-bot2 for Ian Rogers
2019-10-23 0:53 ` [PATCH v2 5/9] perf tools: avoid a malloc for array events Ian Rogers
2019-10-23 8:58 ` Jiri Olsa
2019-10-23 12:38 ` Arnaldo Carvalho de Melo
2019-11-12 11:18 ` [tip: perf/core] perf tools: Avoid a malloc() " tip-bot2 for Ian Rogers
2019-10-23 0:53 ` [PATCH v2 6/9] perf tools: add destructors for parse event terms Ian Rogers
2019-10-23 9:01 ` Jiri Olsa
2019-10-24 19:03 ` Ian Rogers
2019-10-23 0:53 ` [PATCH v2 7/9] perf tools: before yyabort-ing free components Ian Rogers
2019-10-23 0:53 ` [PATCH v2 8/9] perf tools: if pmu configuration fails free terms Ian Rogers
2019-10-23 0:53 ` [PATCH v2 9/9] perf tools: add a deep delete for parse event terms Ian Rogers
2019-10-24 19:01 ` [PATCH v3 0/9] Improvements to memory usage by parse events Ian Rogers
2019-10-24 19:01 ` [PATCH v3 1/9] perf tools: add parse events append error Ian Rogers
2019-10-25 7:58 ` Jiri Olsa
2019-10-25 15:14 ` Ian Rogers
2019-10-28 19:32 ` Jiri Olsa
2019-10-28 21:06 ` Ian Rogers
2019-10-28 21:36 ` Jiri Olsa
2019-11-04 20:37 ` Ian Rogers
2019-10-24 19:01 ` [PATCH v3 2/9] perf tools: splice events onto evlist even on error Ian Rogers
2019-10-25 8:01 ` Jiri Olsa
2019-10-25 15:47 ` Ian Rogers
2019-10-28 21:06 ` Jiri Olsa
2019-10-24 19:01 ` [PATCH v3 3/9] perf tools: ensure config and str in terms are unique Ian Rogers
2019-10-25 8:10 ` Jiri Olsa
2019-10-25 15:52 ` Ian Rogers
2019-10-24 19:01 ` [PATCH v3 4/9] perf tools: move ALLOC_LIST into a function Ian Rogers
2019-10-24 19:01 ` [PATCH v3 5/9] perf tools: avoid a malloc for array events Ian Rogers
2019-10-24 19:01 ` [PATCH v3 6/9] perf tools: add destructors for parse event terms Ian Rogers
2019-10-25 8:27 ` Jiri Olsa
2019-10-25 16:08 ` Ian Rogers
2019-10-28 19:33 ` Jiri Olsa
2019-10-24 19:02 ` [PATCH v3 7/9] perf tools: before yyabort-ing free components Ian Rogers
2019-10-24 19:02 ` [PATCH v3 8/9] perf tools: if pmu configuration fails free terms Ian Rogers
2019-10-24 19:02 ` [PATCH v3 9/9] perf tools: add a deep delete for parse event terms Ian Rogers
2019-10-25 18:08 ` [PATCH v4 0/9] Improvements to memory usage by parse events Ian Rogers
2019-10-25 18:08 ` [PATCH v4 1/9] perf tools: add parse events handle error Ian Rogers
2019-10-25 18:08 ` [PATCH v4 2/9] perf tools: move ALLOC_LIST into a function Ian Rogers
2019-10-25 18:08 ` [PATCH v4 3/9] perf tools: avoid a malloc for array events Ian Rogers
2019-10-25 18:08 ` [PATCH v4 4/9] perf tools: splice events onto evlist even on error Ian Rogers
2019-10-28 21:07 ` Jiri Olsa
2019-10-30 11:56 ` Arnaldo Carvalho de Melo
2019-11-12 11:18 ` [tip: perf/core] perf tools: Splice " tip-bot2 for Ian Rogers
2019-10-25 18:08 ` [PATCH v4 5/9] perf tools: ensure config and str in terms are unique Ian Rogers
2019-10-25 18:08 ` [PATCH v4 6/9] perf tools: add destructors for parse event terms Ian Rogers
2019-10-25 18:08 ` [PATCH v4 7/9] perf tools: before yyabort-ing free components Ian Rogers
2019-10-25 18:08 ` [PATCH v4 8/9] perf tools: if pmu configuration fails free terms Ian Rogers
2019-10-25 18:08 ` [PATCH v4 9/9] perf tools: add a deep delete for parse event terms Ian Rogers
2019-10-30 22:34 ` [PATCH v5 00/10] Improvements to memory usage by parse events Ian Rogers
2019-10-30 22:34 ` [PATCH v5 01/10] perf tools: add parse events handle error Ian Rogers
2019-11-06 14:06 ` Jiri Olsa
2019-11-06 14:29 ` Arnaldo Carvalho de Melo
2019-11-12 11:17 ` [tip: perf/core] perf parse: Add " tip-bot2 for Ian Rogers
2019-10-30 22:34 ` [PATCH v5 02/10] perf tools: move ALLOC_LIST into a function Ian Rogers
2019-10-30 22:34 ` [PATCH v5 03/10] perf tools: avoid a malloc for array events Ian Rogers
2019-10-30 22:34 ` [PATCH v5 04/10] perf tools: splice events onto evlist even on error Ian Rogers
2019-10-30 22:34 ` [PATCH v5 05/10] perf tools: ensure config and str in terms are unique Ian Rogers
2019-11-06 14:25 ` Jiri Olsa
2019-11-06 14:31 ` Arnaldo Carvalho de Melo
2019-11-12 11:17 ` [tip: perf/core] perf parse: Ensure " tip-bot2 for Ian Rogers
2019-10-30 22:34 ` [PATCH v5 06/10] perf tools: add destructors for parse event terms Ian Rogers
2019-11-06 14:24 ` Jiri Olsa
2019-11-06 14:35 ` Arnaldo Carvalho de Melo
2019-11-12 11:17 ` [tip: perf/core] perf parse: Add " tip-bot2 for Ian Rogers
2019-10-30 22:34 ` [PATCH v5 07/10] perf tools: before yyabort-ing free components Ian Rogers
2019-11-06 14:24 ` Jiri Olsa
2019-11-06 14:37 ` Arnaldo Carvalho de Melo
2019-11-12 11:17 ` [tip: perf/core] perf parse: Before " tip-bot2 for Ian Rogers
2019-10-30 22:34 ` [PATCH v5 08/10] perf tools: if pmu configuration fails free terms Ian Rogers
2019-11-06 14:24 ` Jiri Olsa
2019-11-06 14:38 ` Arnaldo Carvalho de Melo
2019-11-12 11:17 ` [tip: perf/core] perf parse: If " tip-bot2 for Ian Rogers
2019-10-30 22:34 ` [PATCH v5 09/10] perf tools: add a deep delete for parse event terms Ian Rogers
2019-11-06 14:24 ` Jiri Olsa
2019-11-06 14:39 ` Arnaldo Carvalho de Melo
2019-11-12 11:17 ` [tip: perf/core] perf parse: Add " tip-bot2 for Ian Rogers
2019-10-30 22:34 ` [PATCH v5 10/10] perf tools: report initial event parsing error Ian Rogers
2019-11-06 14:24 ` Jiri Olsa
2019-11-07 22:14 ` [PATCH v6 00/10] Improvements to memory usage by parse events Ian Rogers
2019-11-07 22:14 ` [PATCH v6 01/10] perf tools: add parse events handle error Ian Rogers
2019-11-07 22:14 ` [PATCH v6 02/10] perf tools: move ALLOC_LIST into a function Ian Rogers
2019-11-07 22:14 ` [PATCH v6 03/10] perf tools: avoid a malloc for array events Ian Rogers
2019-11-07 22:14 ` [PATCH v6 04/10] perf tools: splice events onto evlist even on error Ian Rogers
2019-11-07 22:14 ` [PATCH v6 05/10] perf tools: ensure config and str in terms are unique Ian Rogers
2019-11-07 22:14 ` [PATCH v6 06/10] perf tools: add destructors for parse event terms Ian Rogers
2019-11-07 22:14 ` [PATCH v6 07/10] perf tools: before yyabort-ing free components Ian Rogers
2019-11-07 22:14 ` [PATCH v6 08/10] perf tools: if pmu configuration fails free terms Ian Rogers
2019-11-07 22:14 ` [PATCH v6 09/10] perf tools: add a deep delete for parse event terms Ian Rogers
2019-11-07 22:14 ` [PATCH v6 10/10] perf tools: report initial event parsing error Ian Rogers
2019-11-07 22:23 ` [PATCH v6 00/10] Improvements to memory usage by parse events Arnaldo Carvalho de Melo
2019-11-08 18:15 ` [PATCH] perf tools: report initial event parsing error Ian Rogers
2019-11-08 18:25 ` Arnaldo Carvalho de Melo
2019-11-11 12:02 ` Jiri Olsa
2019-11-16 7:49 ` Ian Rogers
2019-11-11 12:02 ` Jiri Olsa
2019-11-16 7:52 ` Ian Rogers
2019-11-11 12:03 ` Jiri Olsa
2019-11-16 7:53 ` Ian Rogers
2019-11-16 7:46 ` [PATCH v2] " Ian Rogers
2019-11-18 22:16 ` Arnaldo Carvalho de Melo
2019-11-19 16:56 ` [tip: perf/core] perf parse: Report " tip-bot2 for Ian Rogers
2019-11-08 18:18 ` [PATCH v6 00/10] Improvements to memory usage by parse events Ian Rogers
2019-10-23 8:29 ` Jiri Olsa [this message]
2019-11-11 14:25 ` [PATCH] perf tools: avoid reading out of scope array Arnaldo Carvalho de Melo
2019-11-11 20:34 ` Ian Rogers
2019-11-12 11:05 ` Arnaldo Carvalho de Melo
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=20191023082912.GB22919@krava \
--to=jolsa@redhat.com \
--cc=acme@kernel.org \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=clang-built-linux@googlegroups.com \
--cc=eranian@google.com \
--cc=hekuang@huawei.com \
--cc=irogers@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--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 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).