Skip to content

Commit 0e08f13

Browse files
Leo-YanUlrich Hecht
authored andcommitted
perf: arm_spe: Prevent overflow in PERF_IDX2OFF()
[ Upstream commit a29fea30dd93da16652930162b177941abd8c75e ] Cast nr_pages to unsigned long to avoid overflow when handling large AUX buffer sizes (>= 2 GiB). Fixes: d5d9696 ("drivers/perf: Add support for ARMv8.2 Statistical Profiling Extension") Signed-off-by: Leo Yan <leo.yan@arm.com> Signed-off-by: Will Deacon <will@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Ulrich Hecht <uli@kernel.org>
1 parent 158b818 commit 0e08f13

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

drivers/perf/arm_spe_pmu.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ struct arm_spe_pmu {
8585
#define to_spe_pmu(p) (container_of(p, struct arm_spe_pmu, pmu))
8686

8787
/* Convert a free-running index from perf into an SPE buffer offset */
88-
#define PERF_IDX2OFF(idx, buf) ((idx) % ((buf)->nr_pages << PAGE_SHIFT))
88+
#define PERF_IDX2OFF(idx, buf) \
89+
((idx) % ((unsigned long)(buf)->nr_pages << PAGE_SHIFT))
8990

9091
/* Keep track of our dynamic hotplug state */
9192
static enum cpuhp_state arm_spe_pmu_online;

0 commit comments

Comments
 (0)