Skip to content

Commit 823707b

Browse files
4astdavem330
authored andcommitted
bpf: check for reserved flag bits in array and stack maps
Suggested-by: Daniel Borkmann <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 6c90598 commit 823707b

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

kernel/bpf/arraymap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static struct bpf_map *array_map_alloc(union bpf_attr *attr)
5353

5454
/* check sanity of attributes */
5555
if (attr->max_entries == 0 || attr->key_size != 4 ||
56-
attr->value_size == 0)
56+
attr->value_size == 0 || attr->map_flags)
5757
return ERR_PTR(-EINVAL);
5858

5959
if (attr->value_size >= 1 << (KMALLOC_SHIFT_MAX - 1))

kernel/bpf/stackmap.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ static struct bpf_map *stack_map_alloc(union bpf_attr *attr)
3535
if (!capable(CAP_SYS_ADMIN))
3636
return ERR_PTR(-EPERM);
3737

38+
if (attr->map_flags)
39+
return ERR_PTR(-EINVAL);
40+
3841
/* check sanity of attributes */
3942
if (attr->max_entries == 0 || attr->key_size != 4 ||
4043
value_size < 8 || value_size % 8 ||

0 commit comments

Comments
 (0)