lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Wed, 10 Apr 2019 10:10:42 -0300 From: Arnaldo Carvalho de Melo <arnaldo.melo@...il.com> To: Mao Han <han_mao@...ky.com> Cc: linux-kernel@...r.kernel.org, Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...hat.com>, Alexander Shishkin <alexander.shishkin@...ux.intel.com>, Jiri Olsa <jolsa@...hat.com>, Namhyung Kim <namhyung@...nel.org> Subject: Re: [PATCH v3 1/3] perf: use hweight64 instead of hweight_long Em Wed, Apr 10, 2019 at 10:08:41AM -0300, Arnaldo Carvalho de Melo escreveu: > Em Wed, Apr 10, 2019 at 04:16:43PM +0800, Mao Han escreveu: > > On 32-bits platform with more than 32 registers, the 64 bits mask is > > truncate to the lower 32 bits and the return value of hweight_long will > > always smaller than 32. When kernel outputs more than 32 registers, but > > the user perf program only counts 32, there will be a data mismatch > > result to overflow check fail. > > > > CC: Peter Zijlstra <peterz@...radead.org> > > CC: Ingo Molnar <mingo@...hat.com> > > CC: Arnaldo Carvalho de Melo <acme@...nel.org> > > CC: Alexander Shishkin <alexander.shishkin@...ux.intel.com> > > CC: Jiri Olsa <jolsa@...hat.com> > > CC: Namhyung Kim <namhyung@...nel.org> > > > > Signed-off-by: Mao Han <han_mao@...ky.com> > > --- > > tools/perf/util/evsel.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c > > index 7835e05..73c78be 100644 > > --- a/tools/perf/util/evsel.c > > +++ b/tools/perf/util/evsel.c > > @@ -2322,7 +2322,7 @@ int perf_evsel__parse_sample(struct perf_evsel *evsel, union perf_event *event, > > if (data->user_regs.abi) { > > u64 mask = evsel->attr.sample_regs_user; > > > > - sz = hweight_long(mask) * sizeof(u64); > > + sz = hweight64(mask) * sizeof(u64); > > OVERFLOW_CHECK(array, sz, max_size); > > data->user_regs.mask = mask; > > data->user_regs.regs = (u64 *)array; > > Later on, in the same function, perf_evsel__parse_sample() we have: > > data->intr_regs.abi = PERF_SAMPLE_REGS_ABI_NONE; > if (type & PERF_SAMPLE_REGS_INTR) { > OVERFLOW_CHECK_u64(array); > data->intr_regs.abi = *array; > array++; > > if (data->intr_regs.abi != PERF_SAMPLE_REGS_ABI_NONE) { > u64 mask = evsel->attr.sample_regs_intr; > > sz = hweight_long(mask) * sizeof(u64); > OVERFLOW_CHECK(array, sz, max_size); > data->intr_regs.mask = mask; > data->intr_regs.regs = (u64 *)array; > array = (void *)array + sz; > } > } > > You forgot to convert that one, doing it for you, Also in perf_event__sample_event_size() we need to do the same thing, right? - Arnaldo
Powered by blists - more mailing lists