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 26
26
#include <linux/cred.h>
27
27
#include <linux/timekeeping.h>
28
28
#include <linux/ctype.h>
29
+ #include <linux/nospec.h>
29
30
30
31
#define IS_FD_ARRAY (map ) ((map)->map_type == BPF_MAP_TYPE_PROG_ARRAY || \
31
32
(map)->map_type == BPF_MAP_TYPE_PERF_EVENT_ARRAY || \
@@ -102,12 +103,14 @@ const struct bpf_map_ops bpf_map_offload_ops = {
102
103
static struct bpf_map * find_and_alloc_map (union bpf_attr * attr )
103
104
{
104
105
const struct bpf_map_ops * ops ;
106
+ u32 type = attr -> map_type ;
105
107
struct bpf_map * map ;
106
108
int err ;
107
109
108
- if (attr -> map_type >= ARRAY_SIZE (bpf_map_types ))
110
+ if (type >= ARRAY_SIZE (bpf_map_types ))
109
111
return ERR_PTR (- EINVAL );
110
- ops = bpf_map_types [attr -> map_type ];
112
+ type = array_index_nospec (type , ARRAY_SIZE (bpf_map_types ));
113
+ ops = bpf_map_types [type ];
111
114
if (!ops )
112
115
return ERR_PTR (- EINVAL );
113
116
@@ -122,7 +125,7 @@ static struct bpf_map *find_and_alloc_map(union bpf_attr *attr)
122
125
if (IS_ERR (map ))
123
126
return map ;
124
127
map -> ops = ops ;
125
- map -> map_type = attr -> map_type ;
128
+ map -> map_type = type ;
126
129
return map ;
127
130
}
128
131
You can’t perform that action at this time.
0 commit comments