From: Alexei Starovoitov Date: Tue, 8 Mar 2016 05:57:16 +0000 (-0800) Subject: bpf: check for reserved flag bits in array and stack maps X-Git-Tag: v5.15~13995^2~108^2~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=823707b68d6e6c4b1be619b039c7045fef1740e6;p=platform%2Fkernel%2Flinux-starfive.git bpf: check for reserved flag bits in array and stack maps Suggested-by: Daniel Borkmann Signed-off-by: Alexei Starovoitov Signed-off-by: David S. Miller --- diff --git a/kernel/bpf/arraymap.c b/kernel/bpf/arraymap.c index bd3bdf2..76d5a79 100644 --- a/kernel/bpf/arraymap.c +++ b/kernel/bpf/arraymap.c @@ -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)) diff --git a/kernel/bpf/stackmap.c b/kernel/bpf/stackmap.c index 8a60ee1..f0a02c3 100644 --- a/kernel/bpf/stackmap.c +++ b/kernel/bpf/stackmap.c @@ -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 ||