From f01719730bbe04b90ae60c7e9d2b6d3533308502 Mon Sep 17 00:00:00 2001 From: Kan Liang Date: Thu, 28 May 2020 08:19:29 -0700 Subject: perf/x86/intel/uncore: Validate MMIO address before accessing An oops will be triggered, if perf tries to access an invalid address which exceeds the mapped area. Check the address before the actual access to MMIO sapce of an uncore unit. Suggested-by: David Laight Signed-off-by: Kan Liang Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/1590679169-61823-3-git-send-email-kan.liang@linux.intel.com --- arch/x86/events/intel/uncore.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'arch/x86/events/intel/uncore.c') diff --git a/arch/x86/events/intel/uncore.c b/arch/x86/events/intel/uncore.c index b9c28765bf33..cbe32d592aad 100644 --- a/arch/x86/events/intel/uncore.c +++ b/arch/x86/events/intel/uncore.c @@ -132,6 +132,9 @@ u64 uncore_mmio_read_counter(struct intel_uncore_box *box, if (!box->io_addr) return 0; + if (!uncore_mmio_is_valid_offset(box, event->hw.event_base)) + return 0; + return readq(box->io_addr + event->hw.event_base); } -- cgit