|
@@ -1,5 +1,6 @@
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
#include <linux/perf_event.h>
|
|
#include <linux/perf_event.h>
|
|
|
|
+#include <linux/nospec.h>
|
|
#include <asm/intel-family.h>
|
|
#include <asm/intel-family.h>
|
|
|
|
|
|
enum perf_msr_id {
|
|
enum perf_msr_id {
|
|
@@ -158,9 +159,6 @@ static int msr_event_init(struct perf_event *event)
|
|
if (event->attr.type != event->pmu->type)
|
|
if (event->attr.type != event->pmu->type)
|
|
return -ENOENT;
|
|
return -ENOENT;
|
|
|
|
|
|
- if (cfg >= PERF_MSR_EVENT_MAX)
|
|
|
|
- return -EINVAL;
|
|
|
|
-
|
|
|
|
/* unsupported modes and filters */
|
|
/* unsupported modes and filters */
|
|
if (event->attr.exclude_user ||
|
|
if (event->attr.exclude_user ||
|
|
event->attr.exclude_kernel ||
|
|
event->attr.exclude_kernel ||
|
|
@@ -171,6 +169,11 @@ static int msr_event_init(struct perf_event *event)
|
|
event->attr.sample_period) /* no sampling */
|
|
event->attr.sample_period) /* no sampling */
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
+ if (cfg >= PERF_MSR_EVENT_MAX)
|
|
|
|
+ return -EINVAL;
|
|
|
|
+
|
|
|
|
+ cfg = array_index_nospec((unsigned long)cfg, PERF_MSR_EVENT_MAX);
|
|
|
|
+
|
|
if (!msr[cfg].attr)
|
|
if (!msr[cfg].attr)
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
|
|
|