Revert "bpf: Add map and need_defer parameters to .map_fd_put_ptr()"
This reverts commit 80700978cb
which is
commit 20c20bd11a0702ce4dc9300c3da58acf551d9725 upstream.
It breaks the Android kernel abi and can be brought back in the future
in an abi-safe way if it is really needed.
Bug: 161946584
Change-Id: I884aeffbf2f42c9345f083da594f208e6db4bc9d
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
@@ -83,11 +83,7 @@ struct bpf_map_ops {
|
|||||||
/* funcs called by prog_array and perf_event_array map */
|
/* funcs called by prog_array and perf_event_array map */
|
||||||
void *(*map_fd_get_ptr)(struct bpf_map *map, struct file *map_file,
|
void *(*map_fd_get_ptr)(struct bpf_map *map, struct file *map_file,
|
||||||
int fd);
|
int fd);
|
||||||
/* If need_defer is true, the implementation should guarantee that
|
void (*map_fd_put_ptr)(void *ptr);
|
||||||
* the to-be-put element is still alive before the bpf program, which
|
|
||||||
* may manipulate it, exists.
|
|
||||||
*/
|
|
||||||
void (*map_fd_put_ptr)(struct bpf_map *map, void *ptr, bool need_defer);
|
|
||||||
int (*map_gen_lookup)(struct bpf_map *map, struct bpf_insn *insn_buf);
|
int (*map_gen_lookup)(struct bpf_map *map, struct bpf_insn *insn_buf);
|
||||||
u32 (*map_fd_sys_lookup_elem)(void *ptr);
|
u32 (*map_fd_sys_lookup_elem)(void *ptr);
|
||||||
void (*map_seq_show_elem)(struct bpf_map *map, void *key,
|
void (*map_seq_show_elem)(struct bpf_map *map, void *key,
|
||||||
|
@@ -764,7 +764,7 @@ int bpf_fd_array_map_update_elem(struct bpf_map *map, struct file *map_file,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (old_ptr)
|
if (old_ptr)
|
||||||
map->ops->map_fd_put_ptr(map, old_ptr, true);
|
map->ops->map_fd_put_ptr(old_ptr);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -787,7 +787,7 @@ static int fd_array_map_delete_elem(struct bpf_map *map, void *key)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (old_ptr) {
|
if (old_ptr) {
|
||||||
map->ops->map_fd_put_ptr(map, old_ptr, true);
|
map->ops->map_fd_put_ptr(old_ptr);
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
@@ -811,9 +811,8 @@ static void *prog_fd_array_get_ptr(struct bpf_map *map,
|
|||||||
return prog;
|
return prog;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void prog_fd_array_put_ptr(struct bpf_map *map, void *ptr, bool need_defer)
|
static void prog_fd_array_put_ptr(void *ptr)
|
||||||
{
|
{
|
||||||
/* bpf_prog is freed after one RCU or tasks trace grace period */
|
|
||||||
bpf_prog_put(ptr);
|
bpf_prog_put(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1140,9 +1139,8 @@ err_out:
|
|||||||
return ee;
|
return ee;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void perf_event_fd_array_put_ptr(struct bpf_map *map, void *ptr, bool need_defer)
|
static void perf_event_fd_array_put_ptr(void *ptr)
|
||||||
{
|
{
|
||||||
/* bpf_perf_event is freed after one RCU grace period */
|
|
||||||
bpf_event_entry_free_rcu(ptr);
|
bpf_event_entry_free_rcu(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1197,7 +1195,7 @@ static void *cgroup_fd_array_get_ptr(struct bpf_map *map,
|
|||||||
return cgroup_get_from_fd(fd);
|
return cgroup_get_from_fd(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cgroup_fd_array_put_ptr(struct bpf_map *map, void *ptr, bool need_defer)
|
static void cgroup_fd_array_put_ptr(void *ptr)
|
||||||
{
|
{
|
||||||
/* cgroup_put free cgrp after a rcu grace period */
|
/* cgroup_put free cgrp after a rcu grace period */
|
||||||
cgroup_put(ptr);
|
cgroup_put(ptr);
|
||||||
|
@@ -786,7 +786,7 @@ static void htab_put_fd_value(struct bpf_htab *htab, struct htab_elem *l)
|
|||||||
|
|
||||||
if (map->ops->map_fd_put_ptr) {
|
if (map->ops->map_fd_put_ptr) {
|
||||||
ptr = fd_htab_map_get_ptr(map, l);
|
ptr = fd_htab_map_get_ptr(map, l);
|
||||||
map->ops->map_fd_put_ptr(map, ptr, true);
|
map->ops->map_fd_put_ptr(ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2023,7 +2023,7 @@ static void fd_htab_map_free(struct bpf_map *map)
|
|||||||
hlist_nulls_for_each_entry_safe(l, n, head, hash_node) {
|
hlist_nulls_for_each_entry_safe(l, n, head, hash_node) {
|
||||||
void *ptr = fd_htab_map_get_ptr(map, l);
|
void *ptr = fd_htab_map_get_ptr(map, l);
|
||||||
|
|
||||||
map->ops->map_fd_put_ptr(map, ptr, false);
|
map->ops->map_fd_put_ptr(ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2064,7 +2064,7 @@ int bpf_fd_htab_map_update_elem(struct bpf_map *map, struct file *map_file,
|
|||||||
|
|
||||||
ret = htab_map_update_elem(map, key, &ptr, map_flags);
|
ret = htab_map_update_elem(map, key, &ptr, map_flags);
|
||||||
if (ret)
|
if (ret)
|
||||||
map->ops->map_fd_put_ptr(map, ptr, false);
|
map->ops->map_fd_put_ptr(ptr);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@@ -100,7 +100,7 @@ void *bpf_map_fd_get_ptr(struct bpf_map *map,
|
|||||||
return inner_map;
|
return inner_map;
|
||||||
}
|
}
|
||||||
|
|
||||||
void bpf_map_fd_put_ptr(struct bpf_map *map, void *ptr, bool need_defer)
|
void bpf_map_fd_put_ptr(void *ptr)
|
||||||
{
|
{
|
||||||
/* ptr->ops->map_free() has to go through one
|
/* ptr->ops->map_free() has to go through one
|
||||||
* rcu grace period by itself.
|
* rcu grace period by itself.
|
||||||
|
@@ -13,7 +13,7 @@ struct bpf_map *bpf_map_meta_alloc(int inner_map_ufd);
|
|||||||
void bpf_map_meta_free(struct bpf_map *map_meta);
|
void bpf_map_meta_free(struct bpf_map *map_meta);
|
||||||
void *bpf_map_fd_get_ptr(struct bpf_map *map, struct file *map_file,
|
void *bpf_map_fd_get_ptr(struct bpf_map *map, struct file *map_file,
|
||||||
int ufd);
|
int ufd);
|
||||||
void bpf_map_fd_put_ptr(struct bpf_map *map, void *ptr, bool need_defer);
|
void bpf_map_fd_put_ptr(void *ptr);
|
||||||
u32 bpf_map_fd_sys_lookup_elem(void *ptr);
|
u32 bpf_map_fd_sys_lookup_elem(void *ptr);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user