mirror of https://github.com/torvalds/linux.git
libperf mmap: In user mmap rdpmc avoid undefined behavior
A shift left of a signed 64-bit s64 may overflow and result in undefined behavior caught by ubsan. Switch to a u64 instead. Signed-off-by: Ian Rogers <irogers@google.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
de1111f91a
commit
8dc364fa48
|
|
@ -508,7 +508,7 @@ int perf_mmap__read_self(struct perf_mmap *map, struct perf_counts_values *count
|
||||||
idx = READ_ONCE(pc->index);
|
idx = READ_ONCE(pc->index);
|
||||||
cnt = READ_ONCE(pc->offset);
|
cnt = READ_ONCE(pc->offset);
|
||||||
if (pc->cap_user_rdpmc && idx) {
|
if (pc->cap_user_rdpmc && idx) {
|
||||||
s64 evcnt = read_perf_counter(idx - 1);
|
u64 evcnt = read_perf_counter(idx - 1);
|
||||||
u16 width = READ_ONCE(pc->pmc_width);
|
u16 width = READ_ONCE(pc->pmc_width);
|
||||||
|
|
||||||
evcnt <<= 64 - width;
|
evcnt <<= 64 - width;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue