Messages in this thread Patch in this message | | | Date | Fri, 20 Apr 2018 15:14:10 +0200 | From | Peter Zijlstra <> | Subject | [PATCH 3/7] perf,x86: Fix possible Spectre-v1 for x86_pmu::event_map() |
| |
> 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@oracle.com> Signed-off-by: Peter Zijlstra <peterz@infradead.org> --- arch/x86/events/core.c | 2 ++ 1 file changed, 2 insertions(+)
--- a/arch/x86/events/core.c +++ b/arch/x86/events/core.c @@ -424,6 +424,8 @@ int x86_setup_perfctr(struct perf_event if (attr->config >= x86_pmu.max_events) return -EINVAL; + attr->config = array_index_nospec(attr->config, x86_pmu.max_events); + /* * The generic map: */
| |