diff options
author | Andrii Nakryiko <andriin@fb.com> | 2020-03-09 23:40:17 +0100 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2020-03-10 03:58:54 +0100 |
commit | 1d8006abaab4cb90f81add86e8d1bf9411add05a (patch) | |
tree | b6dd24074e513d6fb9845dbfe28b30f2c7dcd671 /kernel | |
parent | bpf: Initialize storage pointers to NULL to prevent freeing garbage pointer (diff) | |
download | linux-1d8006abaab4cb90f81add86e8d1bf9411add05a.tar.xz linux-1d8006abaab4cb90f81add86e8d1bf9411add05a.zip |
bpf: Fix cgroup ref leak in cgroup_bpf_inherit on out-of-memory
There is no compensating cgroup_bpf_put() for each ancestor cgroup in
cgroup_bpf_inherit(). If compute_effective_progs returns error, those cgroups
won't be freed ever. Fix it by putting them in cleanup code path.
Fixes: e10360f815ca ("bpf: cgroup: prevent out-of-order release of cgroup bpf")
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Roman Gushchin <guro@fb.com>
Link: https://lore.kernel.org/bpf/20200309224017.1063297-1-andriin@fb.com
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/bpf/cgroup.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/kernel/bpf/cgroup.c b/kernel/bpf/cgroup.c index b2bc4c335bb1..4f1472409ef8 100644 --- a/kernel/bpf/cgroup.c +++ b/kernel/bpf/cgroup.c @@ -227,6 +227,9 @@ cleanup: for (i = 0; i < NR; i++) bpf_prog_array_free(arrays[i]); + for (p = cgroup_parent(cgrp); p; p = cgroup_parent(p)) + cgroup_bpf_put(p); + percpu_ref_exit(&cgrp->bpf.refcnt); return -ENOMEM; |