]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
bpf: check for reserved flag bits in array and stack maps
authorAlexei Starovoitov <ast@fb.com>
Tue, 8 Mar 2016 05:57:16 +0000 (21:57 -0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 8 Mar 2016 20:28:31 +0000 (15:28 -0500)
Suggested-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
kernel/bpf/arraymap.c
kernel/bpf/stackmap.c

index bd3bdf2486a7b1aa4744f2bd5045ff21e47812cd..76d5a794e4263bb9a57d2b4576b201173324d27f 100644 (file)
@@ -53,7 +53,7 @@ static struct bpf_map *array_map_alloc(union bpf_attr *attr)
 
        /* check sanity of attributes */
        if (attr->max_entries == 0 || attr->key_size != 4 ||
-           attr->value_size == 0)
+           attr->value_size == 0 || attr->map_flags)
                return ERR_PTR(-EINVAL);
 
        if (attr->value_size >= 1 << (KMALLOC_SHIFT_MAX - 1))
index 8a60ee14a9770b83df1f4ccad10349d312d7e591..f0a02c344358d629789037f189d077f3d0662108 100644 (file)
@@ -35,6 +35,9 @@ static struct bpf_map *stack_map_alloc(union bpf_attr *attr)
        if (!capable(CAP_SYS_ADMIN))
                return ERR_PTR(-EPERM);
 
+       if (attr->map_flags)
+               return ERR_PTR(-EINVAL);
+
        /* check sanity of attributes */
        if (attr->max_entries == 0 || attr->key_size != 4 ||
            value_size < 8 || value_size % 8 ||