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 {
@@ -158,9 +159,6 @@ static int msr_event_init(struct perf_event *event)
158
159
if (event -> attr .type != event -> pmu -> type )
159
160
return - ENOENT ;
160
161
161
- if (cfg >= PERF_MSR_EVENT_MAX )
162
- return - EINVAL ;
163
-
164
162
/* unsupported modes and filters */
165
163
if (event -> attr .exclude_user ||
166
164
event -> attr .exclude_kernel ||
@@ -171,6 +169,11 @@ static int msr_event_init(struct perf_event *event)
171
169
event -> attr .sample_period ) /* no sampling */
172
170
return - EINVAL ;
173
171
172
+ if (cfg >= PERF_MSR_EVENT_MAX )
173
+ return - EINVAL ;
174
+
175
+ cfg = array_index_nospec ((unsigned long )cfg , PERF_MSR_EVENT_MAX );
176
+
174
177
if (!msr [cfg ].attr )
175
178
return - EINVAL ;
176
179
You can’t perform that action at this time.
0 commit comments