perf/x86: Fix possible Spectre-v1 indexing for x86_pmu::event_map()
Linux-MTD Mailing List
linux-mtd at lists.infradead.org
Mon May 14 05:59:12 PDT 2018
Gitweb: http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=46b1b577229a091b137831becaa0fae8690ee15a
Commit: 46b1b577229a091b137831becaa0fae8690ee15a
Parent: ef9ee4ad38445a30909c48998624861716f2a994
Author: Peter Zijlstra <peterz at infradead.org>
AuthorDate: Fri Apr 20 14:08:58 2018 +0200
Committer: Ingo Molnar <mingo at kernel.org>
CommitDate: Sat May 5 08:37:28 2018 +0200
perf/x86: Fix possible Spectre-v1 indexing for x86_pmu::event_map()
> arch/x86/events/intel/cstate.c:307 cstate_pmu_event_init() warn: potential spectre issue 'pkg_msr' (local cap)
> arch/x86/events/intel/core.c:337 intel_pmu_event_map() warn: potential spectre issue 'intel_perfmon_event_map'
> arch/x86/events/intel/knc.c:122 knc_pmu_event_map() warn: potential spectre issue 'knc_perfmon_event_map'
> arch/x86/events/intel/p4.c:722 p4_pmu_event_map() warn: potential spectre issue 'p4_general_events'
> arch/x86/events/intel/p6.c:116 p6_pmu_event_map() warn: potential spectre issue 'p6_perfmon_event_map'
> arch/x86/events/amd/core.c:132 amd_pmu_event_map() warn: potential spectre issue 'amd_perfmon_event_map'
Userspace controls @attr, sanitize @attr->config before passing it on
to x86_pmu::event_map().
Reported-by: Dan Carpenter <dan.carpenter at oracle.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz at infradead.org>
Cc: <stable at kernel.org>
Cc: Alexander Shishkin <alexander.shishkin at linux.intel.com>
Cc: Arnaldo Carvalho de Melo <acme at redhat.com>
Cc: Jiri Olsa <jolsa at redhat.com>
Cc: Linus Torvalds <torvalds at linux-foundation.org>
Cc: Peter Zijlstra <peterz at infradead.org>
Cc: Stephane Eranian <eranian at google.com>
Cc: Thomas Gleixner <tglx at linutronix.de>
Cc: Vince Weaver <vincent.weaver at maine.edu>
Signed-off-by: Ingo Molnar <mingo at kernel.org>
---
arch/x86/events/core.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c
index b1be0ac51ce0..45b2b1c93d04 100644
--- a/arch/x86/events/core.c
+++ b/arch/x86/events/core.c
@@ -27,6 +27,7 @@
#include <linux/cpu.h>
#include <linux/bitops.h>
#include <linux/device.h>
+#include <linux/nospec.h>
#include <asm/apic.h>
#include <asm/stacktrace.h>
@@ -424,6 +425,8 @@ int x86_setup_perfctr(struct perf_event *event)
if (attr->config >= x86_pmu.max_events)
return -EINVAL;
+ attr->config = array_index_nospec((unsigned long)attr->config, x86_pmu.max_events);
+
/*
* The generic map:
*/
More information about the linux-mtd-cvs
mailing list