aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/bpf
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-10-09 03:02:35 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-10-09 03:02:35 -0400
commit1236d6bb6e19fc72ffc6bbcdeb1bfefe450e54ee (patch)
tree47da3feee8e263e8c9352c85cf518e624be3c211 /kernel/bpf
parent750b1a6894ecc9b178c6e3d0a1170122971b2036 (diff)
parent8a5776a5f49812d29fe4b2d0a2d71675c3facf3f (diff)
Merge 4.14-rc4 into staging-next
We want the staging/iio fixes in here as well to handle merge issues. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'kernel/bpf')
-rw-r--r--kernel/bpf/core.c2
-rw-r--r--kernel/bpf/devmap.c6
-rw-r--r--kernel/bpf/syscall.c6
-rw-r--r--kernel/bpf/verifier.c7
4 files changed, 15 insertions, 6 deletions
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index 917cc04a0a94..7b62df86be1d 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -1022,7 +1022,7 @@ select_insn:
1022 struct bpf_map *map = (struct bpf_map *) (unsigned long) BPF_R2; 1022 struct bpf_map *map = (struct bpf_map *) (unsigned long) BPF_R2;
1023 struct bpf_array *array = container_of(map, struct bpf_array, map); 1023 struct bpf_array *array = container_of(map, struct bpf_array, map);
1024 struct bpf_prog *prog; 1024 struct bpf_prog *prog;
1025 u64 index = BPF_R3; 1025 u32 index = BPF_R3;
1026 1026
1027 if (unlikely(index >= array->map.max_entries)) 1027 if (unlikely(index >= array->map.max_entries))
1028 goto out; 1028 goto out;
diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c
index 959c9a07f318..e093d9a2c4dd 100644
--- a/kernel/bpf/devmap.c
+++ b/kernel/bpf/devmap.c
@@ -75,8 +75,8 @@ static u64 dev_map_bitmap_size(const union bpf_attr *attr)
75static struct bpf_map *dev_map_alloc(union bpf_attr *attr) 75static struct bpf_map *dev_map_alloc(union bpf_attr *attr)
76{ 76{
77 struct bpf_dtab *dtab; 77 struct bpf_dtab *dtab;
78 int err = -EINVAL;
78 u64 cost; 79 u64 cost;
79 int err;
80 80
81 /* check sanity of attributes */ 81 /* check sanity of attributes */
82 if (attr->max_entries == 0 || attr->key_size != 4 || 82 if (attr->max_entries == 0 || attr->key_size != 4 ||
@@ -108,6 +108,8 @@ static struct bpf_map *dev_map_alloc(union bpf_attr *attr)
108 if (err) 108 if (err)
109 goto free_dtab; 109 goto free_dtab;
110 110
111 err = -ENOMEM;
112
111 /* A per cpu bitfield with a bit per possible net device */ 113 /* A per cpu bitfield with a bit per possible net device */
112 dtab->flush_needed = __alloc_percpu(dev_map_bitmap_size(attr), 114 dtab->flush_needed = __alloc_percpu(dev_map_bitmap_size(attr),
113 __alignof__(unsigned long)); 115 __alignof__(unsigned long));
@@ -128,7 +130,7 @@ static struct bpf_map *dev_map_alloc(union bpf_attr *attr)
128free_dtab: 130free_dtab:
129 free_percpu(dtab->flush_needed); 131 free_percpu(dtab->flush_needed);
130 kfree(dtab); 132 kfree(dtab);
131 return ERR_PTR(-ENOMEM); 133 return ERR_PTR(err);
132} 134}
133 135
134static void dev_map_free(struct bpf_map *map) 136static void dev_map_free(struct bpf_map *map)
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index cb17e1cd1d43..25d074920a00 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -186,15 +186,17 @@ static int bpf_map_alloc_id(struct bpf_map *map)
186 186
187static void bpf_map_free_id(struct bpf_map *map, bool do_idr_lock) 187static void bpf_map_free_id(struct bpf_map *map, bool do_idr_lock)
188{ 188{
189 unsigned long flags;
190
189 if (do_idr_lock) 191 if (do_idr_lock)
190 spin_lock_bh(&map_idr_lock); 192 spin_lock_irqsave(&map_idr_lock, flags);
191 else 193 else
192 __acquire(&map_idr_lock); 194 __acquire(&map_idr_lock);
193 195
194 idr_remove(&map_idr, map->id); 196 idr_remove(&map_idr, map->id);
195 197
196 if (do_idr_lock) 198 if (do_idr_lock)
197 spin_unlock_bh(&map_idr_lock); 199 spin_unlock_irqrestore(&map_idr_lock, flags);
198 else 200 else
199 __release(&map_idr_lock); 201 __release(&map_idr_lock);
200} 202}
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 799b2451ef2d..b914fbe1383e 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -4205,7 +4205,12 @@ static int fixup_bpf_calls(struct bpf_verifier_env *env)
4205 } 4205 }
4206 4206
4207 if (insn->imm == BPF_FUNC_redirect_map) { 4207 if (insn->imm == BPF_FUNC_redirect_map) {
4208 u64 addr = (unsigned long)prog; 4208 /* Note, we cannot use prog directly as imm as subsequent
4209 * rewrites would still change the prog pointer. The only
4210 * stable address we can use is aux, which also works with
4211 * prog clones during blinding.
4212 */
4213 u64 addr = (unsigned long)prog->aux;
4209 struct bpf_insn r4_ld[] = { 4214 struct bpf_insn r4_ld[] = {
4210 BPF_LD_IMM64(BPF_REG_4, addr), 4215 BPF_LD_IMM64(BPF_REG_4, addr),
4211 *insn, 4216 *insn,