diff options
author | Daniel Borkmann <daniel@iogearbox.net> | 2019-11-22 21:07:55 +0100 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2019-11-24 17:03:44 -0800 |
commit | 6332be04c039a72fca32ed0a4265bac58d606bb6 (patch) | |
tree | e6bb35f65a435ed543365e2ad750c3e69cb28e3a /kernel/bpf/core.c | |
parent | 4b3da77b72ad6b3c48c6fe4a395ace7db39a12c5 (diff) | |
download | kernel_replicant_linux-6332be04c039a72fca32ed0a4265bac58d606bb6.tar.gz kernel_replicant_linux-6332be04c039a72fca32ed0a4265bac58d606bb6.tar.bz2 kernel_replicant_linux-6332be04c039a72fca32ed0a4265bac58d606bb6.zip |
bpf: Move bpf_free_used_maps into sleepable section
We later on are going to need a sleepable context as opposed to plain
RCU callback in order to untrack programs we need to poke at runtime
and tracking as well as image update is performed under mutex.
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Link: https://lore.kernel.org/bpf/09823b1d5262876e9b83a8e75df04cf0467357a4.1574452833.git.daniel@iogearbox.net
Diffstat (limited to 'kernel/bpf/core.c')
-rw-r--r-- | kernel/bpf/core.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c index b5945c3aaa8e..0e825c164f1a 100644 --- a/kernel/bpf/core.c +++ b/kernel/bpf/core.c @@ -2003,12 +2003,35 @@ int bpf_prog_array_copy_info(struct bpf_prog_array *array, : 0; } +static void bpf_free_cgroup_storage(struct bpf_prog_aux *aux) +{ + enum bpf_cgroup_storage_type stype; + + for_each_cgroup_storage_type(stype) { + if (!aux->cgroup_storage[stype]) + continue; + bpf_cgroup_storage_release(aux->prog, + aux->cgroup_storage[stype]); + } +} + +static void bpf_free_used_maps(struct bpf_prog_aux *aux) +{ + int i; + + bpf_free_cgroup_storage(aux); + for (i = 0; i < aux->used_map_cnt; i++) + bpf_map_put(aux->used_maps[i]); + kfree(aux->used_maps); +} + static void bpf_prog_free_deferred(struct work_struct *work) { struct bpf_prog_aux *aux; int i; aux = container_of(work, struct bpf_prog_aux, work); + bpf_free_used_maps(aux); if (bpf_prog_is_dev_bound(aux)) bpf_prog_offload_destroy(aux->prog); #ifdef CONFIG_PERF_EVENTS |