Skip to content

Commit

Permalink
Merge tag 'perf-urgent-for-mingo-4.14-20171027' of git://git.kernel.o…
Browse files Browse the repository at this point in the history
…rg/pub/scm/linux/kernel/git/acme/linux into perf/urgent

Pull perf/urgent fixes from Arnaldo Carvalho de Melo:

- Fix memory corruption in the annotation routines because of zero
  length symbols (asm ones) (Ravi Bangoria)

- Fix printing garbage as an error message when re-running the
  lexer events matcher (Jiri Olsa)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Ingo Molnar committed Oct 28, 2017
2 parents 11224e1 + 9445464 commit 4139433
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
12 changes: 11 additions & 1 deletion tools/perf/util/annotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -606,9 +606,19 @@ static struct arch *arch__find(const char *name)
int symbol__alloc_hist(struct symbol *sym)
{
struct annotation *notes = symbol__annotation(sym);
const size_t size = symbol__size(sym);
size_t size = symbol__size(sym);
size_t sizeof_sym_hist;

/*
* Add buffer of one element for zero length symbol.
* When sample is taken from first instruction of
* zero length symbol, perf still resolves it and
* shows symbol name in perf report and allows to
* annotate it.
*/
if (size == 0)
size = 1;

/* Check for overflow when calculating sizeof_sym_hist */
if (size > (SIZE_MAX - sizeof(struct sym_hist)) / sizeof(struct sym_hist_entry))
return -1;
Expand Down
8 changes: 6 additions & 2 deletions tools/perf/util/parse-events.l
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ do { \
yycolumn += yyleng; \
} while (0);

#define USER_REJECT \
yycolumn -= yyleng; \
REJECT

%}

%x mem
Expand Down Expand Up @@ -335,8 +339,8 @@ r{num_raw_hex} { return raw(yyscanner); }
{num_hex} { return value(yyscanner, 16); }

{modifier_event} { return str(yyscanner, PE_MODIFIER_EVENT); }
{bpf_object} { if (!isbpf(yyscanner)) REJECT; return str(yyscanner, PE_BPF_OBJECT); }
{bpf_source} { if (!isbpf(yyscanner)) REJECT; return str(yyscanner, PE_BPF_SOURCE); }
{bpf_object} { if (!isbpf(yyscanner)) USER_REJECT; return str(yyscanner, PE_BPF_OBJECT); }
{bpf_source} { if (!isbpf(yyscanner)) USER_REJECT; return str(yyscanner, PE_BPF_SOURCE); }
{name} { return pmu_str_check(yyscanner); }
"/" { BEGIN(config); return '/'; }
- { return '-'; }
Expand Down

0 comments on commit 4139433

Please sign in to comment.