Skip to content

Commit 3a66de2

Browse files
anakryikogregkh
authored andcommitted
bpf: Fix cgroup ref leak in cgroup_bpf_inherit on out-of-memory
commit 1d8006a upstream. 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: e10360f ("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 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent c45a302 commit 3a66de2

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

‎kernel/bpf/cgroup.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,9 @@ int cgroup_bpf_inherit(struct cgroup *cgrp)
228228
for (i = 0; i < NR; i++)
229229
bpf_prog_array_free(arrays[i]);
230230

231+
for (p = cgroup_parent(cgrp); p; p = cgroup_parent(p))
232+
cgroup_bpf_put(p);
233+
231234
percpu_ref_exit(&cgrp->bpf.refcnt);
232235

233236
return -ENOMEM;

0 commit comments

Comments
 (0)