On Sun, May 22, 2011 at 08:47:26AM +0000, tip-bot for Frederic Weisbecker wrote: > Commit-ID: a285412479b6d5af3e48273a92ec2f1987df8cd1 > Gitweb: http://git.kernel.org/tip/a285412479b6d5af3e48273a92ec2f1987df8cd1 > Author: Frederic Weisbecker <fweisbec@xxxxxxxxx> > AuthorDate: Sat, 21 May 2011 19:33:04 +0200 > Committer: Frederic Weisbecker <fweisbec@xxxxxxxxx> > CommitDate: Sun, 22 May 2011 03:38:36 +0200 > > perf tools: Pre-check sample size before parsing > > Check that the total size of the sample fields having a fixed > size do not exceed the one of the whole event. This robustifies > the sample parsing. > > Signed-off-by: Frederic Weisbecker <fweisbec@xxxxxxxxx> > Cc: Ingo Molnar <mingo@xxxxxxx> > Cc: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx> > Cc: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx> > Cc: Stephane Eranian <eranian@xxxxxxxxxx> > --- > tools/perf/builtin-test.c | 4 +++- > tools/perf/util/event.c | 16 ++++++++++++++++ > tools/perf/util/event.h | 12 +++++++++++- > tools/perf/util/evsel.c | 6 +++++- > tools/perf/util/python.c | 5 +++-- > tools/perf/util/session.c | 1 + > tools/perf/util/session.h | 2 ++ > 7 files changed, 41 insertions(+), 5 deletions(-) > > diff --git a/tools/perf/builtin-test.c b/tools/perf/builtin-test.c > index 11e3c84..44d7df2 100644 > --- a/tools/perf/builtin-test.c > +++ b/tools/perf/builtin-test.c > @@ -474,6 +474,7 @@ static int test__basic_mmap(void) > unsigned int nr_events[nsyscalls], > expected_nr_events[nsyscalls], i, j; > struct perf_evsel *evsels[nsyscalls], *evsel; > + int sample_size = perf_sample_size(attr.sample_type); > > for (i = 0; i < nsyscalls; ++i) { > char name[64]; > @@ -558,7 +559,8 @@ static int test__basic_mmap(void) > goto out_munmap; > } > > - perf_event__parse_sample(event, attr.sample_type, false, &sample); > + perf_event__parse_sample(event, attr.sample_type, sample_size, > + false, &sample); > evsel = perf_evlist__id2evsel(evlist, sample.id); > if (evsel == NULL) { > pr_debug("event with id %" PRIu64 > diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c > index 1023f67..17c1c3c 100644 > --- a/tools/perf/util/event.c > +++ b/tools/perf/util/event.c > @@ -35,6 +35,22 @@ const char *perf_event__name(unsigned int id) > return perf_event__names[id]; > } > > +int perf_sample_size(u64 sample_type) > +{ > + u64 mask = sample_type & PERF_SAMPLE_MASK; > + int size = 0; > + int i; > + > + for (i = 0; i < 64; i++) { > + if ((mask << i) & 1) Should be (mask & (1 << i)), will fix that too :) -- To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html
![]() |