aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/bpf/devmap.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2017-10-22 08:36:53 -0400
committerDavid S. Miller <davem@davemloft.net>2017-10-22 08:39:14 -0400
commitf8ddadc4db6c7b7029b6d0e0d9af24f74ad27ca2 (patch)
tree0a6432aba336bae42313613f4c891bcfce02bd4e /kernel/bpf/devmap.c
parentbdd091bab8c631bd2801af838e344fad34566410 (diff)
parentb5ac3beb5a9f0ef0ea64cd85faf94c0dc4de0e42 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
There were quite a few overlapping sets of changes here. Daniel's bug fix for off-by-ones in the new BPF branch instructions, along with the added allowances for "data_end > ptr + x" forms collided with the metadata additions. Along with those three changes came veritifer test cases, which in their final form I tried to group together properly. If I had just trimmed GIT's conflict tags as-is, this would have split up the meta tests unnecessarily. In the socketmap code, a set of preemption disabling changes overlapped with the rename of bpf_compute_data_end() to bpf_compute_data_pointers(). Changes were made to the mv88e6060.c driver set addr method which got removed in net-next. The hyperv transport socket layer had a locking change in 'net' which overlapped with a change of socket state macro usage in 'net-next'. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'kernel/bpf/devmap.c')
-rw-r--r--kernel/bpf/devmap.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c
index e5d3de7cff2e..ebdef54bf7df 100644
--- a/kernel/bpf/devmap.c
+++ b/kernel/bpf/devmap.c
@@ -72,7 +72,7 @@ static LIST_HEAD(dev_map_list);
72 72
73static u64 dev_map_bitmap_size(const union bpf_attr *attr) 73static u64 dev_map_bitmap_size(const union bpf_attr *attr)
74{ 74{
75 return BITS_TO_LONGS(attr->max_entries) * sizeof(unsigned long); 75 return BITS_TO_LONGS((u64) attr->max_entries) * sizeof(unsigned long);
76} 76}
77 77
78static struct bpf_map *dev_map_alloc(union bpf_attr *attr) 78static struct bpf_map *dev_map_alloc(union bpf_attr *attr)
@@ -81,6 +81,9 @@ static struct bpf_map *dev_map_alloc(union bpf_attr *attr)
81 int err = -EINVAL; 81 int err = -EINVAL;
82 u64 cost; 82 u64 cost;
83 83
84 if (!capable(CAP_NET_ADMIN))
85 return ERR_PTR(-EPERM);
86
84 /* check sanity of attributes */ 87 /* check sanity of attributes */
85 if (attr->max_entries == 0 || attr->key_size != 4 || 88 if (attr->max_entries == 0 || attr->key_size != 4 ||
86 attr->value_size != 4 || attr->map_flags & ~DEV_CREATE_FLAG_MASK) 89 attr->value_size != 4 || attr->map_flags & ~DEV_CREATE_FLAG_MASK)
@@ -114,8 +117,9 @@ static struct bpf_map *dev_map_alloc(union bpf_attr *attr)
114 err = -ENOMEM; 117 err = -ENOMEM;
115 118
116 /* A per cpu bitfield with a bit per possible net device */ 119 /* A per cpu bitfield with a bit per possible net device */
117 dtab->flush_needed = __alloc_percpu(dev_map_bitmap_size(attr), 120 dtab->flush_needed = __alloc_percpu_gfp(dev_map_bitmap_size(attr),
118 __alignof__(unsigned long)); 121 __alignof__(unsigned long),
122 GFP_KERNEL | __GFP_NOWARN);
119 if (!dtab->flush_needed) 123 if (!dtab->flush_needed)
120 goto free_dtab; 124 goto free_dtab;
121 125