Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Ian Rogers and committed by
Arnaldo Carvalho de Melo
8dc364fa de1111f9

+1 -1
+1 -1
tools/lib/perf/mmap.c
··· 508 508 idx = READ_ONCE(pc->index); 509 509 cnt = READ_ONCE(pc->offset); 510 510 if (pc->cap_user_rdpmc && idx) { 511 - s64 evcnt = read_perf_counter(idx - 1); 511 + u64 evcnt = read_perf_counter(idx - 1); 512 512 u16 width = READ_ONCE(pc->pmc_width); 513 513 514 514 evcnt <<= 64 - width;