diff options
| author | James Morris <james.morris@microsoft.com> | 2018-12-17 11:24:28 -0800 |
|---|---|---|
| committer | James Morris <james.morris@microsoft.com> | 2018-12-17 11:24:28 -0800 |
| commit | 8bd8ea195f6d135a8d85201116314eb5237ad7e7 (patch) | |
| tree | 3ef99e468f0b4b13cc11002aa60c4451e326191b /kernel/bpf/queue_stack_maps.c | |
| parent | 1072bd678547f8663cfb81a22fdb50c589e4976e (diff) | |
| parent | 7566ec393f4161572ba6f11ad5171fd5d59b0fbd (diff) | |
| download | cachepc-linux-8bd8ea195f6d135a8d85201116314eb5237ad7e7.tar.gz cachepc-linux-8bd8ea195f6d135a8d85201116314eb5237ad7e7.zip | |
Merge tag 'v4.20-rc7' into next-general
Sync with Linux 4.20-rc7, to pick up: Revert "ovl: relax permission checking on underlying layers"
Diffstat (limited to 'kernel/bpf/queue_stack_maps.c')
| -rw-r--r-- | kernel/bpf/queue_stack_maps.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/kernel/bpf/queue_stack_maps.c b/kernel/bpf/queue_stack_maps.c index 8bbd72d3a121..b384ea9f3254 100644 --- a/kernel/bpf/queue_stack_maps.c +++ b/kernel/bpf/queue_stack_maps.c @@ -7,6 +7,7 @@ #include <linux/bpf.h> #include <linux/list.h> #include <linux/slab.h> +#include <linux/capability.h> #include "percpu_freelist.h" #define QUEUE_STACK_CREATE_FLAG_MASK \ @@ -45,8 +46,12 @@ static bool queue_stack_map_is_full(struct bpf_queue_stack *qs) /* Called from syscall */ static int queue_stack_map_alloc_check(union bpf_attr *attr) { + if (!capable(CAP_SYS_ADMIN)) + return -EPERM; + /* check sanity of attributes */ if (attr->max_entries == 0 || attr->key_size != 0 || + attr->value_size == 0 || attr->map_flags & ~QUEUE_STACK_CREATE_FLAG_MASK) return -EINVAL; @@ -63,15 +68,10 @@ static struct bpf_map *queue_stack_map_alloc(union bpf_attr *attr) { int ret, numa_node = bpf_map_attr_numa_node(attr); struct bpf_queue_stack *qs; - u32 size, value_size; - u64 queue_size, cost; - - size = attr->max_entries + 1; - value_size = attr->value_size; - - queue_size = sizeof(*qs) + (u64) value_size * size; + u64 size, queue_size, cost; - cost = queue_size; + size = (u64) attr->max_entries + 1; + cost = queue_size = sizeof(*qs) + size * attr->value_size; if (cost >= U32_MAX - PAGE_SIZE) return ERR_PTR(-E2BIG); |
