diff options
author | Will Deacon <will.deacon@arm.com> | 2013-08-20 11:47:39 +0100 |
---|---|---|
committer | Catalin Marinas <catalin.marinas@arm.com> | 2013-08-20 12:05:57 +0100 |
commit | 868f6fea8fa63f09acbfa93256d0d2abdcabff79 (patch) | |
tree | f208c1d84324fc007b6bb19595ce8756ebe39047 /arch | |
parent | c095ba7224d8edc71dcef0d655911399a8bd4a3f (diff) |
arm64: perf: fix array out of bounds access in armpmu_map_hw_event()
This is a port of d9f966357b14 ("ARM: 7810/1: perf: Fix array out of
bounds access in armpmu_map_hw_event()") to arm64, which fixes an oops
in the arm64 perf backend found as a result of Vince's fuzzing tool.
Cc: <stable@vger.kernel.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm64/kernel/perf_event.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/arch/arm64/kernel/perf_event.c b/arch/arm64/kernel/perf_event.c index 9ba33c40cdf..2012646fb46 100644 --- a/arch/arm64/kernel/perf_event.c +++ b/arch/arm64/kernel/perf_event.c @@ -107,7 +107,12 @@ armpmu_map_cache_event(const unsigned (*cache_map) static int armpmu_map_event(const unsigned (*event_map)[PERF_COUNT_HW_MAX], u64 config) { - int mapping = (*event_map)[config]; + int mapping; + + if (config >= PERF_COUNT_HW_MAX) + return -EINVAL; + + mapping = (*event_map)[config]; return mapping == HW_OP_UNSUPPORTED ? -ENOENT : mapping; } |