]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
bpf: Fix cgroup ref leak in cgroup_bpf_inherit on out-of-memory
authorAndrii Nakryiko <andriin@fb.com>
Mon, 9 Mar 2020 22:40:17 +0000 (15:40 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 1 Apr 2020 09:00:12 +0000 (11:00 +0200)
commit3a66de200ff954ee1a5fa7ca40dae40882fc160d
tree8607f596b11e191d2a12c67d86b2fabeea1ec48b
parentc45a3023ec8bb8d72880cbd8c828788d53012938
bpf: Fix cgroup ref leak in cgroup_bpf_inherit on out-of-memory

commit 1d8006abaab4cb90f81add86e8d1bf9411add05a 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: 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
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
kernel/bpf/cgroup.c