]> git.ipfire.org Git - people/arne_f/kernel.git/commitdiff
bpf: do not test for PCPU_MIN_UNIT_SIZE before percpu allocations
authorDaniel Borkmann <daniel@iogearbox.net>
Tue, 17 Oct 2017 14:55:54 +0000 (16:55 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 19 Oct 2017 12:13:50 +0000 (13:13 +0100)
PCPU_MIN_UNIT_SIZE is an implementation detail of the percpu
allocator. Given we support __GFP_NOWARN now, lets just let
the allocation request fail naturally instead. The two call
sites from BPF mistakenly assumed __GFP_NOWARN would work, so
no changes needed to their actual __alloc_percpu_gfp() calls
which use the flag already.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
kernel/bpf/arraymap.c
kernel/bpf/hashtab.c

index 98c0f00c3f5e05007287de1a1636c4e6722beed7..e2636737b69bd8bdd1a690e5453616effb9800d5 100644 (file)
@@ -98,7 +98,7 @@ static struct bpf_map *array_map_alloc(union bpf_attr *attr)
        array_size += (u64) attr->max_entries * elem_size * num_possible_cpus();
 
        if (array_size >= U32_MAX - PAGE_SIZE ||
-           elem_size > PCPU_MIN_UNIT_SIZE || bpf_array_alloc_percpu(array)) {
+           bpf_array_alloc_percpu(array)) {
                bpf_map_area_free(array);
                return ERR_PTR(-ENOMEM);
        }
index 431126f31ea3c90648366295e2b77fd3bb79b6e7..6533f08d1238e136895a5cf0665be31d7b23df51 100644 (file)
@@ -317,10 +317,6 @@ static struct bpf_map *htab_map_alloc(union bpf_attr *attr)
                 */
                goto free_htab;
 
-       if (percpu && round_up(htab->map.value_size, 8) > PCPU_MIN_UNIT_SIZE)
-               /* make sure the size for pcpu_alloc() is reasonable */
-               goto free_htab;
-
        htab->elem_size = sizeof(struct htab_elem) +
                          round_up(htab->map.key_size, 8);
        if (percpu)