]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
coresight: trbe: Prevent overflow in PERF_IDX2OFF()
authorLeo Yan <leo.yan@arm.com>
Wed, 17 Sep 2025 17:41:38 +0000 (18:41 +0100)
committerWill Deacon <will@kernel.org>
Thu, 18 Sep 2025 14:23:58 +0000 (15:23 +0100)
Cast nr_pages to unsigned long to avoid overflow when handling large
AUX buffer sizes (>= 2 GiB).

Fixes: 3fbf7f011f24 ("coresight: sink: Add TRBE driver")
Signed-off-by: Leo Yan <leo.yan@arm.com>
Signed-off-by: Will Deacon <will@kernel.org>
drivers/hwtracing/coresight/coresight-trbe.c

index 8267dd1a2130d37d9507791620ea7bc8cbcd675c..8f426f94e32a15fd26e6c4e42385a5d93a7b7c1a 100644 (file)
@@ -23,7 +23,8 @@
 #include "coresight-self-hosted-trace.h"
 #include "coresight-trbe.h"
 
-#define PERF_IDX2OFF(idx, buf) ((idx) % ((buf)->nr_pages << PAGE_SHIFT))
+#define PERF_IDX2OFF(idx, buf) \
+       ((idx) % ((unsigned long)(buf)->nr_pages << PAGE_SHIFT))
 
 /*
  * A padding packet that will help the user space tools