Skip to content

Commit 4139433

Browse files
author
Ingo Molnar
committed
Merge tag 'perf-urgent-for-mingo-4.14-20171027' of git://git.kernel.org/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 <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2 parents 11224e1 + 9445464 commit 4139433

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

tools/perf/util/annotate.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,9 +606,19 @@ static struct arch *arch__find(const char *name)
606606
int symbol__alloc_hist(struct symbol *sym)
607607
{
608608
struct annotation *notes = symbol__annotation(sym);
609-
const size_t size = symbol__size(sym);
609+
size_t size = symbol__size(sym);
610610
size_t sizeof_sym_hist;
611611

612+
/*
613+
* Add buffer of one element for zero length symbol.
614+
* When sample is taken from first instruction of
615+
* zero length symbol, perf still resolves it and
616+
* shows symbol name in perf report and allows to
617+
* annotate it.
618+
*/
619+
if (size == 0)
620+
size = 1;
621+
612622
/* Check for overflow when calculating sizeof_sym_hist */
613623
if (size > (SIZE_MAX - sizeof(struct sym_hist)) / sizeof(struct sym_hist_entry))
614624
return -1;

tools/perf/util/parse-events.l

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ do { \
154154
yycolumn += yyleng; \
155155
} while (0);
156156

157+
#define USER_REJECT \
158+
yycolumn -= yyleng; \
159+
REJECT
160+
157161
%}
158162

159163
%x mem
@@ -335,8 +339,8 @@ r{num_raw_hex} { return raw(yyscanner); }
335339
{num_hex} { return value(yyscanner, 16); }
336340

337341
{modifier_event} { return str(yyscanner, PE_MODIFIER_EVENT); }
338-
{bpf_object} { if (!isbpf(yyscanner)) REJECT; return str(yyscanner, PE_BPF_OBJECT); }
339-
{bpf_source} { if (!isbpf(yyscanner)) REJECT; return str(yyscanner, PE_BPF_SOURCE); }
342+
{bpf_object} { if (!isbpf(yyscanner)) USER_REJECT; return str(yyscanner, PE_BPF_OBJECT); }
343+
{bpf_source} { if (!isbpf(yyscanner)) USER_REJECT; return str(yyscanner, PE_BPF_SOURCE); }
340344
{name} { return pmu_str_check(yyscanner); }
341345
"/" { BEGIN(config); return '/'; }
342346
- { return '-'; }

0 commit comments

Comments
 (0)