File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change 1
1
// SPDX-License-Identifier: GPL-2.0
2
2
#include <linux/perf_event.h>
3
+ #include <linux/nospec.h>
3
4
#include <asm/intel-family.h>
4
5
5
6
enum perf_msr_id {
@@ -145,9 +146,6 @@ static int msr_event_init(struct perf_event *event)
145
146
if (event -> attr .type != event -> pmu -> type )
146
147
return - ENOENT ;
147
148
148
- if (cfg >= PERF_MSR_EVENT_MAX )
149
- return - EINVAL ;
150
-
151
149
/* unsupported modes and filters */
152
150
if (event -> attr .exclude_user ||
153
151
event -> attr .exclude_kernel ||
@@ -158,6 +156,11 @@ static int msr_event_init(struct perf_event *event)
158
156
event -> attr .sample_period ) /* no sampling */
159
157
return - EINVAL ;
160
158
159
+ if (cfg >= PERF_MSR_EVENT_MAX )
160
+ return - EINVAL ;
161
+
162
+ cfg = array_index_nospec ((unsigned long )cfg , PERF_MSR_EVENT_MAX );
163
+
161
164
if (!msr [cfg ].attr )
162
165
return - EINVAL ;
163
166
You can’t perform that action at this time.
0 commit comments